你如何处理ASP.net webapplications中的插入/更新/删除场景?

时间:2017-07-20 22:39:35

标签: c# asp.net angularjs asp.net-web-api

我有一个UI(角度JS),用户希望能够add,update or delete给定SoftwareImage的多个计划(参见下面的API模型)和后端(ASP.net web api) )我希望能够处理这些情况,以下是我们在UI和后端之间的算法,但它似乎是一种非常黑客的方式,我想得到专家的意见,你如何处理这种情况?

namespace Dashboard.Model.ApiModels
{
    public class PostcommitSchedule
    {
        public string SoftwareImage { get; set; }
        public List<PostcommitdayTime> PostcommitdayTime { get; set; }

    }

    public class PostcommitdayTime
    {
        public string day { get; set; }
        public string Time { get; set; }
    }

}

SELECT查询:

SELECT si.software_image,pbs.day_of_week_id,pbs.time_of_day FROM postcommitbuild_schedule pbs
join software_images si on si.software_image_id=pbs.software_image_id
where si.software_image='LNX.LA.3.6'

算法

 If empty object
      Delete all records
 Else
   Run a select query(see above)  to see if there are any existing records for the given SoftwareImage(SI)

    If records exits
     Delete the existing records 
     Insert the new records
   Else
     Insert the new records

0 个答案:

没有答案