public CreatePmsSummaryResponse CreatePmsSummary(CreatePmsSummaryRequest request) { var response = new CreatePmsSummaryResponse(); try { var pmsSummary = request.MapTo<PmsSummary>(); DataContext.PmsSummaries.Add(pmsSummary); DataContext.SaveChanges(); response.Message = "Configuration has been added successfully"; response.IsSuccess = true; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return response; }
public CreatePmsSummaryResponse CreatePmsSummary(CreatePmsSummaryRequest request) { var response = new CreatePmsSummaryResponse(); try { var pmsSummary = request.MapTo<PmsSummary>(); var isExisted = DataContext.PmsSummaries.FirstOrDefault(x => x.IsActive); if (request.IsActive && isExisted != null) { response.Message = string.Format(@"There is one Pms Summary has actived already, You have to unactivate first."); return response; } DataContext.PmsSummaries.Add(pmsSummary); DataContext.SaveChanges(); response.Message = "Configuration has been added successfully"; response.IsSuccess = true; } catch (DbUpdateException dbUpdateException) { response.Message = dbUpdateException.Message; } return response; }