public IActionResult Post([FromBody] OfficeCommutationDto ride)
 {
     try
     {
         if (ride == null)
         {
             return(BadRequest());
         }
         else
         {
             var res = _officeCommutation.AddOfficeCommutation(ride);
             if (res == 0)
             {
                 return(BadRequest());
             }
             else
             {
                 return(Ok(res));
             }
         }
     }
     catch (Exception ex)
     {
         //logger.LogError(ex, ex.Message);
         return(BadRequest());
     }
 }
 public int AddOfficeCommutation(OfficeCommutationDto officeDto)
 {
     try
     {
         int insertedId = 0;
         if (!cabODbContext.OfficeCommutation.Any(x => x.Location1 == Int32.Parse(officeDto.Location1) && x.Location2 == Int32.Parse(officeDto.Location2) && x.IsDeleted == false))
         {
             var commutation = new OfficeCommutation
             {
                 Location1 = Int32.Parse(officeDto.Location1),
                 Location2 = Int32.Parse(officeDto.Location2),
                 CabId     = Int32.Parse(officeDto.CabId),
                 IsDeleted = false
             };
             cabODbContext.OfficeCommutation.Add(commutation);
             cabODbContext.SaveChanges();
             insertedId = commutation.Id;
         }
         return(insertedId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public int UpdateCommutation(int updateId, OfficeCommutationDto update)
 {
     try
     {
         var result = cabODbContext.OfficeCommutation.Where(x => x.Id == updateId).FirstOrDefault();
         result.CabId = Int32.Parse(update.CabId);
         cabODbContext.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public IActionResult Put(int id, [FromBody] OfficeCommutationDto update)
 {
     try
     {
         if (id != 0)
         {
             var a = _officeCommutation.UpdateCommutation(id, update);
             return(Ok(a));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         //logger.LogError(ex, ex.Message);
         return(BadRequest());
     }
 }