예제 #1
0
 public async Task<int> Save(T_Customer_Task model)
 {
     using (db = new KBLDataContext())
     {
         var entity = await (from t in db.CustomerTasks
                             where t.TaskId == model.TaskId
                             select t).FirstOrDefaultAsync();
         if (entity == null)
         {
             entity = await (from t in db.CustomerTasks
                             where t.CId == model.CId
                             orderby t.StartDate descending
                             select t).FirstOrDefaultAsync();
             if (entity != null)
             {
                 model.Describe = entity.Describe;
                 model.Other = entity.Other;
                 model.During = (model.StartDate - entity.StartDate).Value.Days + "";
                 model.Review = (model.StartDate - entity.StartDate).Value.Days + "";
             }
             db.CustomerTasks.Add(model);
         }
         else
         {
             entity.StartDate = model.StartDate;
             entity.Describe = model.Describe;
             entity.Review = model.Review;
             entity.ReviewStatus = model.ReviewStatus;
             entity.During = model.During;
             entity.Other = model.Other;
             db.Entry(entity).State = EntityState.Modified;
         }
         return await db.SaveChangesAsync();
     }
 }
예제 #2
0
 public async Task<object> Save(T_JSON model)
 {
     object effects = 0;
     T_Customer_Task task = new T_Customer_Task();
     if (model.Input0 != null)
     {
         string s = string.Empty;
         s = POSTJson.ResolveTJSON(model);
         task = JsonConvert.DeserializeObject<T_Customer_Task>(s);
         effects = await T_Customer_BLL.SaveCustomerTask(task);
     }
     return Ok(new
     {
         statusCode = 200,
         result = effects
     });
 }
예제 #3
0
 public static async Task<object> SaveCustomerTask(T_Customer_Task model)
 {
     using (T_Customer_Task_Entities entity = new T_Customer_Task_Entities())
     {
         return await entity.Save(model);
     }
 }