示例#1
0
 public ActionResult setUserTreaty(List <UserTreaty> data, int id)
 {
     foreach (var t in data)
     {
         if (t.InTreaty)
         {
             var treaty = enregRepository.GetTreaty(t.id);
             if (treaty == null)
             {
                 return(new JsonnResult {
                     Data = new { success = false, message = "Договор не найден" }
                 });
             }
             if (!enregRepository.IsTreatyInUser(t.id, id))
             {
                 enregRepository.AddTreatyToUser(t.id, id);
             }
         }
         else
         {
             if (enregRepository.IsTreatyInUser(t.id, id))
             {
                 enregRepository.RemoveTreatyFromUser(t.id, id);
             }
         }
     }
     return(new JsonnResult {
         Data = new { success = true, message = "Сохранено", data }
     });
 }