Beispiel #1
0
 public IActionResult Insert([FromBody] SchedulesWriteDTO dto)
 {
     try
     {
         var model = mapper.Map <Schedules>(dto);
         if (model != null)
         {
             repository.Insert(model);
             var result = repository.SaveChanges();
             if (result)
             {
                 return(Ok());
             }
         }
         return(NotFound());
     }
     catch (System.Exception msg)
     {
         return(NotFound(msg));
     }
 }
Beispiel #2
0
 public IActionResult Update(int id, [FromBody] SchedulesWriteDTO dto)
 {
     try
     {
         var isExist = repository.GetById(id);
         if (isExist != null)
         {
             mapper.Map(dto, isExist);
             repository.Update(isExist);
             var result = repository.SaveChanges();
             if (result)
             {
                 return(Ok());
             }
         }
         return(NotFound());
     }
     catch (System.Exception msg)
     {
         return(NotFound(msg));
     }
 }