public static void validateAddCancelDriver(CancelDriverInfo cancelDriverInfo) { if (cancelDriverInfo.Zonetypeid == 0) { throw new DataValidationException($"Zonetypeid does not exists"); } if (string.IsNullOrEmpty(cancelDriverInfo.PaymentStatus)) { throw new DataValidationException($"PaymentStatus does not exists"); } if (string.IsNullOrEmpty(cancelDriverInfo.ArrivalStatus)) { throw new DataValidationException($"ArrivalStatus does not exists"); } if (string.IsNullOrEmpty(cancelDriverInfo.CancelReasonArabic)) { throw new DataValidationException($"CancelReasonArabic does not exists"); } if (string.IsNullOrEmpty(cancelDriverInfo.CancelReasonEnglish)) { throw new DataValidationException($"CancelReasonEnglish does not exists"); } if (string.IsNullOrEmpty(cancelDriverInfo.CancelReasonSpanish)) { throw new DataValidationException($"CancelReasonSpanish does not exists"); } }
public bool EditDriver(TaxiAppzDBContext context, CancelDriverInfo cancelDriverInfo, LoggedInUser loggedInUser) { var roleExist = context.TabDriverCancellation.FirstOrDefault(t => t.IsDelete == false && t.Zonetypeid == cancelDriverInfo.Zonetypeid); if (roleExist == null) { throw new DataValidationException($"Tab driver cancellation does not exists"); } var tabDriverCancellation = context.TabDriverCancellation.Where(r => r.DriverCancelId == cancelDriverInfo.Id && r.IsDelete == false).FirstOrDefault(); if (tabDriverCancellation != null) { tabDriverCancellation.Arrivalstatus = cancelDriverInfo.ArrivalStatus; tabDriverCancellation.CancellationReasonArabic = cancelDriverInfo.CancelReasonArabic; tabDriverCancellation.CancellationReasonEnglish = cancelDriverInfo.CancelReasonEnglish; tabDriverCancellation.CancellationReasonSpanish = cancelDriverInfo.CancelReasonSpanish; tabDriverCancellation.Paymentstatus = cancelDriverInfo.PaymentStatus; tabDriverCancellation.Zonetypeid = cancelDriverInfo.Zonetypeid; tabDriverCancellation.UpdatedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now); tabDriverCancellation.UpdatedBy = loggedInUser.Email; context.Update(tabDriverCancellation); context.SaveChanges(); return(true); } return(false); }
public IActionResult EditDriver(CancelDriverInfo cancelDriverInfo) { try { Validator.validateEditCancelDriver(cancelDriverInfo); DACancel dACancel = new DACancel(); return(this.OKResponse(dACancel.EditDriver(_context, cancelDriverInfo, User.ToAppUser()) == true ? "Updated Successfully" : "Updation Failed")); } catch (DataValidationException ex) { return(this.KnowOperationError(ex.Message)); } }
public CancelDriverInfo GetbyDriverCancelId(long driverCancelId, TaxiAppzDBContext context) { try { CancelDriverInfo cancelDriverInfo = new CancelDriverInfo(); var drivers = context.TabDriverCancellation.Where(u => u.DriverCancelId == driverCancelId && u.IsDelete == false).FirstOrDefault(); if (drivers != null) { cancelDriverInfo.Id = drivers.DriverCancelId; cancelDriverInfo.Zonetypeid = drivers.Zonetypeid; cancelDriverInfo.PaymentStatus = drivers.Paymentstatus; cancelDriverInfo.CancelReasonEnglish = drivers.CancellationReasonEnglish; cancelDriverInfo.CancelReasonArabic = drivers.CancellationReasonArabic; cancelDriverInfo.CancelReasonSpanish = drivers.CancellationReasonSpanish; cancelDriverInfo.ArrivalStatus = drivers.Arrivalstatus; } return(cancelDriverInfo == null ? null : cancelDriverInfo); } catch (Exception ex) { Extention.insertlog(ex.Message, "Admin", "GetbyDriverCancelId", context); return(null); } }