public async Task <ApiResponse> Handle(AddProjectIndicatorCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { ProjectIndicators indicator = new ProjectIndicators(); indicator.CreatedById = request.CreatedById; indicator.IsDeleted = false; indicator.CreatedDate = request.CreatedDate; await _dbContext.ProjectIndicators.AddAsync(indicator); await _dbContext.SaveChangesAsync(); indicator.IndicatorCode = ProjectUtility.GenerateCode(indicator.ProjectIndicatorId); await _dbContext.SaveChangesAsync(); int count = await _dbContext.ProjectIndicators.Where(x => x.IsDeleted == false).CountAsync(); response.data.ProjectIndicator = new ProjectIndicatorViewModel(); response.data.TotalCount = count; response.data.ProjectIndicator.ProjectIndicatorId = indicator.ProjectIndicatorId; response.data.ProjectIndicator.IndicatorCode = indicator.IndicatorCode; response.StatusCode = StaticResource.successStatusCode; response.Message = StaticResource.SuccessText; } catch (Exception exception) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + exception.Message; } return(response); }
public async Task <ApiResponse> Handle(AddContractContentCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var recordExists = await _dbContext.ContractTypeContent.FirstOrDefaultAsync(x => x.EmployeeContractTypeId == request.EmployeeContractTypeId); if (recordExists == null) { ContractTypeContent obj = _mapper.Map <ContractTypeContent>(request); obj.IsDeleted = false; await _dbContext.ContractTypeContent.AddAsync(obj); await _dbContext.SaveChangesAsync(); } else { recordExists.ContentDari = request.ContentDari; recordExists.ContentEnglish = request.ContentEnglish; _dbContext.ContractTypeContent.Update(recordExists); await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddNewEmployeeCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { EmployeeDetail obj = _mapper.Map <EmployeeDetail>(request); obj.IsDeleted = false; await _dbContext.EmployeeDetail.AddAsync(obj); await _dbContext.SaveChangesAsync(); OfficeDetail OfficeDetail = await _dbContext.OfficeDetail.FirstOrDefaultAsync(x => x.OfficeId == request.OfficeId && x.IsDeleted == false); EmployeeDetail emp = await _dbContext.EmployeeDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.EmployeeID == obj.EmployeeID); emp.EmployeeCode = "E" + obj.EmployeeID; _dbContext.EmployeeDetail.Update(emp); await _dbContext.SaveChangesAsync(); EmployeeProfessionalDetailModel empprofessional = new EmployeeProfessionalDetailModel { EmployeeId = obj.EmployeeID, EmployeeTypeId = request.EmployeeTypeId, OfficeId = request.OfficeId, CreatedById = request.CreatedById, CreatedDate = request.CreatedDate, IsDeleted = request.IsDeleted, ProfessionId = request.ProfessionId, TinNumber = request.TinNumber }; EmployeeProfessionalDetail obj1 = _mapper.Map <EmployeeProfessionalDetail>(empprofessional); await _dbContext.EmployeeProfessionalDetail.AddAsync(obj1); await _dbContext.SaveChangesAsync(); UserDetails user = await _dbContext.UserDetails.FirstOrDefaultAsync(x => x.AspNetUserId == request.CreatedById && x.IsDeleted == false); LoggerDetailsModel loggerObj = new LoggerDetailsModel(); loggerObj.NotificationId = (int)Common.Enums.LoggerEnum.EmployeeCreated; loggerObj.IsRead = false; loggerObj.UserName = user.FirstName + " " + user.LastName; loggerObj.UserId = request.CreatedById; loggerObj.LoggedDetail = "Employee " + obj.EmployeeName + " Created"; loggerObj.CreatedDate = request.CreatedDate; response.LoggerDetailsModel = loggerObj; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(ApproveJobCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var jobInfo = await _dbContext.JobDetails.FirstOrDefaultAsync(c => c.JobId == request.JobId && c.IsDeleted == false); jobInfo.IsApproved = true; jobInfo.ModifiedById = request.ModifiedById; jobInfo.ModifiedDate = request.ModifiedDate; await _dbContext.SaveChangesAsync(); var jobPriceInfo = await _dbContext.JobPriceDetails.FirstOrDefaultAsync(c => c.JobId == request.JobId); jobPriceInfo.IsInvoiceApproved = true; jobPriceInfo.ModifiedById = request.ModifiedById; jobPriceInfo.ModifiedDate = request.ModifiedDate; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Job Approved"; response.data.jobListTotalCount = await _dbContext.JobDetails.CountAsync(x => x.IsDeleted == false); response.data.JobDetails = _dbContext.JobDetails.Where(x => x.IsDeleted == false).ToList(); } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEmployeeApplyLeaveCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var existrecord = await _dbContext.AssignLeaveToEmployee.FirstOrDefaultAsync(x => x.EmployeeId == request.EmployeeApplyLeave[0].EmployeeId && x.LeaveReasonId == request.EmployeeApplyLeave[0].LeaveReasonId); int balanceleave = (int)existrecord.AssignUnit - (int)(existrecord.UsedLeaveUnit == null ? 0 : existrecord.UsedLeaveUnit); if (balanceleave >= request.EmployeeApplyLeave.Count) { List <EmployeeApplyLeave> applyleavelist = new List <EmployeeApplyLeave>(); foreach (var list in request.EmployeeApplyLeave) { EmployeeApplyLeave obj = new EmployeeApplyLeave(); obj.EmployeeId = list.EmployeeId; obj.FromDate = list.FromDate; obj.ToDate = list.ToDate; obj.LeaveReasonId = list.LeaveReasonId; obj.Remarks = list.Remarks; obj.FinancialYearId = existrecord.FinancialYearId; obj.CreatedById = request.CreatedById; obj.CreatedDate = DateTime.UtcNow; obj.IsDeleted = false; applyleavelist.Add(obj); } await _dbContext.EmployeeApplyLeave.AddRangeAsync(applyleavelist); await _dbContext.SaveChangesAsync(); if (existrecord != null) { int?usedleaveunit = existrecord.UsedLeaveUnit == null ? 0 : existrecord.UsedLeaveUnit; existrecord.UsedLeaveUnit = usedleaveunit + request.EmployeeApplyLeave.Count; existrecord.ModifiedById = request.ModifiedById; existrecord.ModifiedDate = DateTime.UtcNow; existrecord.IsDeleted = false; _dbContext.AssignLeaveToEmployee.Update(existrecord); await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } else { response.StatusCode = StaticResource.failStatusCode; response.Message = "More than leave cannot apply from balance leave."; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(DeleteCandidateDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { HiringRequestCandidates projectCandidateDetail = new HiringRequestCandidates(); ProjectHiringRequestDetail hrDetail = new ProjectHiringRequestDetail(); if (request.HiringRequestId != 0) { projectCandidateDetail = await _dbContext.HiringRequestCandidates .FirstOrDefaultAsync(x => x.IsDeleted == false && x.HiringRequestId == request.HiringRequestId && x.CandidateId == request.CandidateId); if (projectCandidateDetail != null) { projectCandidateDetail.IsDeleted = true; projectCandidateDetail.ModifiedById = request.ModifiedById; projectCandidateDetail.ModifiedDate = request.ModifiedDate; await _dbContext.SaveChangesAsync(); // note: to update filled vacancire in hiring request detail page hrDetail = await _dbContext.ProjectHiringRequestDetail .FirstOrDefaultAsync(x => x.HiringRequestId == request.HiringRequestId && x.IsDeleted == false); if (hrDetail == null) { throw new Exception("Hiring Job not found"); } int count = await _dbContext.HiringRequestCandidates .CountAsync(x => x.HiringRequestId == request.HiringRequestId && x.IsDeleted == false && x.IsSelected); hrDetail.FilledVacancies = count; hrDetail.ModifiedById = request.ModifiedById; hrDetail.ModifiedDate = request.ModifiedDate; await _dbContext.SaveChangesAsync(); } else { throw new Exception("No Candidate found"); } } response.ResponseData = hrDetail; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(ApproveInvoiceCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var invoiceGeneration = _dbContext.InvoiceGeneration.AsQueryable().Where(x => x.JobId == request.jobId && x.IsDeleted == false).FirstOrDefault(); if (invoiceGeneration != null) { var invoiceDetails = _dbContext.InvoiceApproval.AsQueryable().Where(x => x.JobId == request.jobId).FirstOrDefault(); if (invoiceDetails == null) { InvoiceApproval obj = new InvoiceApproval(); obj.IsDeleted = false; obj.JobId = request.jobId; obj.IsInvoiceApproved = true; obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; await _dbContext.InvoiceApproval.AddAsync(obj); await _dbContext.SaveChangesAsync(); } else { var existRecord = await _dbContext.InvoiceApproval.FirstOrDefaultAsync(x => x.IsDeleted == false && x.JobId == request.jobId); if (existRecord != null) { existRecord.IsInvoiceApproved = true; existRecord.IsDeleted = false; existRecord.ModifiedById = request.ModifiedById; existRecord.ModifiedDate = request.ModifiedDate; await _dbContext.SaveChangesAsync(); } } List <ScheduleDetails> scheduleDetails = await _dbContext.ScheduleDetails.Where(x => x.IsDeleted == false && x.JobId == request.jobId).ToListAsync(); scheduleDetails.ForEach(x => x.IsActive = false); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Invoice Approved successfully"; } else { response.StatusCode = StaticResource.notFoundCode; response.Message = "Invoice Not yet generated"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddProjectSubActivityDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { ProjectActivityDetail obj = _mapper.Map <AddProjectSubActivityDetailCommand, ProjectActivityDetail>(request); //Note : check for all the subactivity are completed or not. ProjectActivityDetail parent = await _dbContext.ProjectActivityDetail .FirstOrDefaultAsync(x => x.IsDeleted == false && x.ActivityId == request.ParentId && x.StatusId == (int)ProjectPhaseType.Completed); obj.StatusId = (int)ProjectPhaseType.Planning; obj.CreatedDate = request.CreatedDate; obj.IsDeleted = false; obj.CreatedById = request.CreatedById; await _dbContext.ProjectActivityDetail.AddAsync(obj); await _dbContext.SaveChangesAsync(); ProjectActivityModel actvityModel = new ProjectActivityModel() { ActivityDescription = obj.ActivityDescription, ActivityId = obj.ActivityId, StatusId = obj.StatusId, ActivityName = obj.ActivityName, ActualEndDate = obj.ActualEndDate, ActualStartDate = obj.ActualStartDate, BudgetLineId = obj.BudgetLineId, ParentId = obj.ParentId, Target = obj.Target, PlannedEndDate = obj.PlannedEndDate, PlannedStartDate = obj.PlannedStartDate, EmployeeID = obj.EmployeeID, SubActivityTitle = obj.SubActivityTitle }; if (parent != null) { parent.StatusId = (int)ProjectPhaseType.Implementation; await _dbContext.SaveChangesAsync(); actvityModel.StatusId = parent.StatusId; } response.data.ProjectActivityModel = actvityModel; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditPensionRateCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var lst = await _dbContext.EmployeePensionRate.FirstOrDefaultAsync(x => x.IsDefault == true); if (request.IsDefault == true) { if (lst != null) { lst.IsDefault = false; _dbContext.EmployeePensionRate.Update(lst); await _dbContext.SaveChangesAsync(); } } if (request.IsDefault == false) { if (lst == null) { request.IsDefault = true; } if (lst.IsDefault == true && lst.FinancialYearId == request.FinancialYearId) { request.IsDefault = true; } else { request.IsDefault = false; } } EmployeePensionRate obj = await _dbContext.EmployeePensionRate.FirstOrDefaultAsync(x => x.FinancialYearId == request.FinancialYearId); obj.FinancialYearId = request.FinancialYearId; obj.PensionRate = request.PensionRate; obj.IsDefault = (request.IsDefault == false && lst == null) ? true : request.IsDefault; obj.IsDefault = true; obj.ModifiedById = request.ModifiedById; obj.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditSelectedDistrictsCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { if (request.DistrictID != null) { var districtExist = _dbContext.DistrictMultiSelect.Where(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); if (districtExist.Any()) { _dbContext.DistrictMultiSelect.RemoveRange(districtExist); await _dbContext.SaveChangesAsync(); } List <DistrictMultiSelect> districtList = new List <DistrictMultiSelect>(); var selectedDistricts = await _dbContext.DistrictDetail.Where(x => request.DistrictID.Contains(x.DistrictID)).ToListAsync(); foreach (var item in selectedDistricts) { DistrictMultiSelect _data = new DistrictMultiSelect(); _data.DistrictID = item.DistrictID; _data.ProjectId = request.ProjectId; _data.IsDeleted = false; _data.CreatedById = request.CreatedById; _data.ProvinceId = item.ProvinceID.Value; _data.CreatedDate = DateTime.UtcNow; districtList.Add(_data); } //Add _dbContext.DistrictMultiSelect.AddRange(districtList); await _dbContext.SaveChangesAsync(); } //response.CommonId.Id = Convert.ToInt32(_detail.SecurityConsiderationId); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditSecurityConsiderationCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { if (request.SecurityConsiderationId != null) { bool securityPresent = _dbContext.SecurityConsiderationMultiSelect.Any(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); if (securityPresent) { var securityExist = _dbContext.SecurityConsiderationMultiSelect.Where(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); _dbContext.SecurityConsiderationMultiSelect.RemoveRange(securityExist); await _dbContext.SaveChangesAsync(); } List <SecurityConsiderationMultiSelect> securityList = new List <SecurityConsiderationMultiSelect>(); foreach (var item in request.SecurityConsiderationId) { SecurityConsiderationMultiSelect _data = new SecurityConsiderationMultiSelect(); _data.SecurityConsiderationId = item.Value; _data.ProjectId = request.ProjectId; _data.IsDeleted = false; _data.CreatedById = request.CreatedById; _data.CreatedDate = DateTime.UtcNow; securityList.Add(_data); } //Add _dbContext.SecurityConsiderationMultiSelect.AddRange(securityList); await _dbContext.SaveChangesAsync(); } //response.CommonId.Id = Convert.ToInt32(_detail.SecurityConsiderationId); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditProjectBudgetLineDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { ProjectBudgetLineDetail obj = _mapper.Map <AddEditProjectBudgetLineDetailCommand, ProjectBudgetLineDetail>(request); if (request.BudgetLineId == null) { obj.CreatedDate = request.CreatedDate; obj.IsDeleted = false; obj.CreatedById = request.CreatedById; await _dbContext.ProjectBudgetLineDetail.AddAsync(obj); if (obj.BudgetLineId != 0) { obj.BudgetCode = await _iProjectServices.GetProjectBudgetLineCode(obj); await _dbContext.SaveChangesAsync(); } } else { ProjectBudgetLineDetail projectBudgetLineDetail = _dbContext.ProjectBudgetLineDetail .FirstOrDefault(x => x.IsDeleted == false && x.BudgetLineId == request.BudgetLineId); projectBudgetLineDetail.BudgetCode = obj.BudgetCode; projectBudgetLineDetail.BudgetName = obj.BudgetName; projectBudgetLineDetail.CurrencyId = obj.CurrencyId; projectBudgetLineDetail.InitialBudget = obj.InitialBudget; projectBudgetLineDetail.ProjectJobId = obj.ProjectJobId; obj.ModifiedById = request.ModifiedById; obj.ModifiedDate = request.ModifiedDate; obj.IsDeleted = false; await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditPlayoutMinutesCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { bool IsExist = await _dbContext.PlayoutMinutes.AnyAsync(x => x.IsDeleted == false && x.ScheduleId == request.ScheduleId); if (!IsExist) { PlayoutMinutes objPlayoutMinutes = new PlayoutMinutes { TotalMinutes = request.TotalMinutes, DroppedMinutes = request.DroppedMinutes, ScheduleId = request.ScheduleId, CreatedById = request.CreatedById, CreatedDate = DateTime.Now, IsDeleted = false }; await _dbContext.PlayoutMinutes.AddAsync(objPlayoutMinutes); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Playout Minutes Added Successfully"; } else { var objPlayoutMinutes = await _dbContext.PlayoutMinutes.FirstOrDefaultAsync(x => x.IsDeleted == false && x.ScheduleId == request.ScheduleId); objPlayoutMinutes.IsDeleted = false; objPlayoutMinutes.ScheduleId = request.ScheduleId; objPlayoutMinutes.ModifiedById = request.ModifiedById; objPlayoutMinutes.ModifiedDate = DateTime.Now; objPlayoutMinutes.TotalMinutes = request.TotalMinutes; objPlayoutMinutes.DroppedMinutes = request.DroppedMinutes; await _dbContext.SaveChangesAsync(); response.data.playoutMinutesDetails = objPlayoutMinutes; response.StatusCode = StaticResource.successStatusCode; response.Message = "Playout minutes Updated successfully"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditChartOfAccountCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { if (request != null) { ChartOfAccountNew accountDetail = await _dbContext.ChartOfAccountNew.FirstOrDefaultAsync(x => x.ChartOfAccountNewId == request.ChartOfAccountNewId); if (accountDetail != null) { accountDetail.AccountName = request.AccountName?.Trim(); accountDetail.AccountTypeId = request.AccountTypeId; accountDetail.AccountFilterTypeId = request.AccountFilterTypeId; accountDetail.ModifiedDate = request.ModifiedDate; accountDetail.IsDeleted = false; await _dbContext.SaveChangesAsync(); if (accountDetail.AccountLevelId == (int)AccountLevels.SubLevel) { bool inputLevelAccountExists = await _dbContext.ChartOfAccountNew.AnyAsync(x => x.IsDeleted == false && x.ParentID == accountDetail.ChartOfAccountNewId); //Update only if input level account exists on sub level account if (inputLevelAccountExists) { // Updated all input-level accounts' account types and balance types if true await UpdateBalanceMetadataForInputAccounts(accountDetail); } } response.StatusCode = StaticResource.successStatusCode; response.Message = StaticResource.SuccessText; } else { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.NoDataFound; } } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditFinancialCriteriaCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); FinancialCriteriaDetail _detail = new FinancialCriteriaDetail(); try { _detail = await _dbContext.FinancialCriteriaDetail.FirstOrDefaultAsync(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); if (_detail == null) { _detail = new FinancialCriteriaDetail { ProjectActivities = request.ProjectActivities, Operational = request.Operational, Overhead_Admin = request.Overhead_Admin, Lump_Sum = request.Lump_Sum, ProjectId = request.ProjectId.Value, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.FinancialCriteriaDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); } else { _detail.ProjectActivities = request.ProjectActivities; _detail.Operational = request.Operational; _detail.Overhead_Admin = request.Overhead_Admin; _detail.Lump_Sum = request.Lump_Sum; _detail.ProjectId = request.ProjectId.Value; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditEmployeeSalaryDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var existrecord = await _dbContext.EmployeePayroll.Where(x => x.EmployeeID == request.EmployeePayroll[0].EmployeeId).ToListAsync(); _dbContext.EmployeePayroll.RemoveRange(existrecord); await _dbContext.SaveChangesAsync(); List <EmployeePayroll> employeepayrolllist = new List <EmployeePayroll>(); foreach (var list in request.EmployeePayroll) { EmployeePayroll obj = new EmployeePayroll(); if (list.HeadTypeId == (int)SalaryHeadType.GENERAL && list.MonthlyAmount == 0) { throw new Exception("Basic Pay cannot be Zero"); } obj.EmployeeID = list.EmployeeId; obj.CurrencyId = list.CurrencyId; obj.HeadTypeId = list.HeadTypeId; obj.SalaryHeadId = list.SalaryHeadId; obj.MonthlyAmount = list.MonthlyAmount; obj.PaymentType = list.PaymentType; obj.PensionRate = list.PensionRate; obj.AccountNo = list.AccountNo; obj.TransactionTypeId = list.TransactionTypeId; obj.IsDeleted = false; employeepayrolllist.Add(obj); } await _dbContext.EmployeePayroll.AddRangeAsync(employeepayrolllist); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditProjectProgramCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { if (request != null) { var existRecord = await _dbContext.ProjectProgram.FirstOrDefaultAsync(x => x.IsDeleted == false && x.ProjectId == request.ProjectId); if (existRecord == null) { ProjectProgram obj = new ProjectProgram(); obj.ProjectId = request.ProjectId; obj.ProgramId = request.ProgramId; obj.IsDeleted = false; obj.CreatedById = request.CreatedById; obj.CreatedDate = DateTime.UtcNow; await _dbContext.ProjectProgram.AddAsync(obj); await _dbContext.SaveChangesAsync(); } else { if (existRecord != null) { existRecord.ProjectId = request.ProjectId; existRecord.ProgramId = request.ProgramId; existRecord.IsDeleted = false; existRecord.ModifiedById = request.ModifiedById; existRecord.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } } response.StatusCode = 200; response.Message = "Success"; } else { throw new Exception("Project Program Not Selected"); } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditSalaryHeadCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var existrecord = await _dbContext.SalaryHeadDetails.FirstOrDefaultAsync(x => x.SalaryHeadId == request.SalaryHeadId); if (existrecord != null) { existrecord.HeadName = request.HeadName; existrecord.AccountNo = request.AccountNo; existrecord.TransactionTypeId = request.TransactionTypeId; existrecord.Description = request.Description; existrecord.HeadTypeId = request.HeadTypeId; existrecord.ModifiedById = request.ModifiedById; existrecord.ModifiedDate = request.ModifiedDate; existrecord.IsDeleted = false; await _dbContext.SaveChangesAsync(); } if (request.SaveForAll) { List <EmployeePayroll> employeePayrollList = await _dbContext.EmployeePayroll.Where(x => x.IsDeleted == false && x.SalaryHeadId == request.SalaryHeadId) .ToListAsync(); if (employeePayrollList.Any()) { employeePayrollList.ForEach(x => { x.AccountNo = request.AccountNo; x.TransactionTypeId = request.TransactionTypeId; x.HeadTypeId = request.HeadTypeId; }); await _dbContext.SaveChangesAsync(); } } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddSalaryHeadCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { SalaryHeadDetails obj = _mapper.Map <SalaryHeadDetails>(request); obj.IsDeleted = false; await _dbContext.SalaryHeadDetails.AddAsync(obj); await _dbContext.SaveChangesAsync(); List <int> employeeIds = await _dbContext.EmployeeDetail.Where(x => x.IsDeleted == false && x.EmployeeTypeId == (int)EmployeeTypeStatus.Active) .Select(x => x.EmployeeID) .ToListAsync(); if (employeeIds.Any()) { List <EmployeePayroll> employeePayrollList = new List <EmployeePayroll>(); foreach (int employeeid in employeeIds) { EmployeePayroll employeePayroll = new EmployeePayroll(); employeePayroll.IsDeleted = false; employeePayroll.AccountNo = request.AccountNo; employeePayroll.SalaryHeadId = obj.SalaryHeadId; employeePayroll.HeadTypeId = request.HeadTypeId; employeePayroll.AccountNo = request.AccountNo; employeePayroll.TransactionTypeId = request.TransactionTypeId; employeePayroll.MonthlyAmount = (double)request.MonthlyAmount; employeePayrollList.Add(employeePayroll); } await _dbContext.EmployeePayroll.AddRangeAsync(employeePayrollList); await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditEligibilityCriteriaDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); EligibilityCriteriaDetail _detail = new EligibilityCriteriaDetail(); try { _detail = await _dbContext.EligibilityCriteriaDetail.FirstOrDefaultAsync(x => x.ProjectId == request.ProjectId && x.IsDeleted == false); if (_detail == null) { _detail = new EligibilityCriteriaDetail { DonorCriteriaMet = request.DonorCriteriaMet, EligibilityDealine = request.EligibilityDealine, CoPartnership = request.CoPartnership, ProjectId = request.ProjectId, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.EligibilityCriteriaDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); } else { _detail.DonorCriteriaMet = request.DonorCriteriaMet; _detail.EligibilityDealine = request.EligibilityDealine; _detail.CoPartnership = request.CoPartnership; _detail.ProjectId = request.ProjectId; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.data.eligibilityCriteriaDetail = _detail; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditFinancialProjectDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); FinancialProjectDetail _detail = new FinancialProjectDetail(); try { _detail = await _dbContext.FinancialProjectDetail.FirstOrDefaultAsync(x => x.ProjectId == request.ProjectId && x.FinancialProjectDetailId == request.FinancialProjectDetailId && x.IsDeleted == false); if (_detail == null) { _detail = new FinancialProjectDetail { ProjectId = request.ProjectId, ProjectSelectionId = request.ProjectSelectionId, ProjectName = request.ProjectName, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.FinancialProjectDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); } else { _detail.ProjectId = request.ProjectId; _detail.ProjectSelectionId = request.ProjectSelectionId; _detail.ProjectName = request.ProjectName; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.CommonId.Id = Convert.ToInt32(_detail.ProjectSelectionId); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEditTargetBeneficiaryCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); TargetBeneficiaryDetail _detail = new TargetBeneficiaryDetail(); try { _detail = await _dbContext.TargetBeneficiaryDetail.FirstOrDefaultAsync(x => x.ProjectId == request.ProjectId && x.TargetId == request.TargetId && x.IsDeleted == false); if (_detail == null) { _detail = new TargetBeneficiaryDetail { TargetType = request.TargetType, TargetName = request.TargetName, ProjectId = request.ProjectId, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.UtcNow }; await _dbContext.TargetBeneficiaryDetail.AddAsync(_detail); await _dbContext.SaveChangesAsync(); } else { _detail.TargetType = request.TargetType; _detail.TargetName = request.TargetName; _detail.ProjectId = request.ProjectId; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.CommonId.LongId = _detail.TargetId; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditEmployeeHistoryOutsideCountryCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var existRecord = await _dbContext.EmployeeHistoryOutsideCountry.FirstOrDefaultAsync(x => x.IsDeleted == false && x.EmployeeHistoryOutsideCountryId == request.EmployeeHistoryOutsideCountryId); if (existRecord != null) { existRecord.IsDeleted = false; existRecord.ModifiedById = request.CreatedById; existRecord.ModifiedDate = DateTime.Now; _mapper.Map(request, existRecord); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } else { response.StatusCode = StaticResource.failStatusCode; response.Message = "Record not found"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(DeleteProjectJobCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var projectJobDetails = await _dbContext.ProjectJobDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.ProjectJobId == request.JobId); if (projectJobDetails != null) { projectJobDetails.ModifiedById = request.ModifiedById; projectJobDetails.ModifiedDate = request.ModifiedDate; projectJobDetails.IsDeleted = true; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Poject Job deleted successfully"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(ApproveAdvanceCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var record = await _dbContext.Advances.FirstOrDefaultAsync(x => x.AdvancesId == request.AdvancesId && x.IsApproved == false && x.IsDeleted == false); if (record != null) { record.IsApproved = true; record.ModifiedById = request.ModifiedById; record.ModifiedDate = DateTime.Now; record.AppraisalApprovedDate = DateTime.Now; _dbContext.Advances.Update(record); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } else { response.StatusCode = StaticResource.failStatusCode; response.Message = "Approval Failed"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditDonorEligibilityDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { DonorEligibilityCriteria _detail = await _dbContext.DonorEligibilityCriteria.FirstOrDefaultAsync(x => x.DonorEligibilityDetailId == request.DonorEligibilityDetailId && x.IsDeleted == false); if (_detail != null) { _detail.Name = request.Name; _detail.IsDeleted = false; _detail.ModifiedById = request.ModifiedById; _detail.ModifiedDate = DateTime.UtcNow; await _dbContext.SaveChangesAsync(); } response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(EditEmployeeAssignLeaveCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var existrecord = await _dbContext.AssignLeaveToEmployee.FirstOrDefaultAsync(x => x.IsDeleted == false && x.LeaveId == request.LeaveId); if (existrecord != null) { existrecord.AssignUnit = request.AssignUnit; existrecord.ModifiedById = request.ModifiedById; existrecord.ModifiedDate = request.ModifiedDate; existrecord.IsDeleted = request.IsDeleted; _dbContext.AssignLeaveToEmployee.Update(existrecord); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(UpdatePayrollAccountHeadCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { PayrollAccountHead xPayrollAccountHead = await _dbContext.PayrollAccountHead.FirstOrDefaultAsync(x => x.PayrollHeadId == request.PayrollHeadId); xPayrollAccountHead.AccountNo = request.AccountNo; xPayrollAccountHead.Description = request.Description; xPayrollAccountHead.PayrollHeadId = request.PayrollHeadId; xPayrollAccountHead.PayrollHeadName = request.PayrollHeadName; xPayrollAccountHead.PayrollHeadTypeId = request.PayrollHeadTypeId; xPayrollAccountHead.TransactionTypeId = request.TransactionTypeId; xPayrollAccountHead.ModifiedById = request.ModifiedById; xPayrollAccountHead.ModifiedDate = request.ModifiedDate; xPayrollAccountHead.IsDeleted = false; await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddEmployeeLanguagesCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { EmployeeLanguages employeeLanguages = new EmployeeLanguages { EmployeeId = request.EmployeeId, LanguageId = request.LanguageId, Listening = request.Listening, Reading = request.Reading, Speaking = request.Speaking, Writing = request.Writing, IsDeleted = false, CreatedById = request.CreatedById, CreatedDate = DateTime.Now }; await _dbContext.EmployeeLanguages.AddAsync(employeeLanguages); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } return(response); }
public async Task <ApiResponse> Handle(AddOpportunityControlCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { ProjectOpportunityControl obj = new ProjectOpportunityControl { ProjectId = request.ProjectId, UserID = request.UserId, RoleId = request.UserId, CreatedDate = request.CreatedDate, CreatedById = request.CreatedById, IsDeleted = false }; // validation await ValidateOpportunityControl(null, request.ProjectId, request.UserId, request.RoleId); await _dbContext.ProjectOpportunityControl.AddAsync(obj); await _dbContext.SaveChangesAsync(); response.CommonId.LongId = obj.Id; response.StatusCode = StaticResource.successStatusCode; response.Message = StaticResource.SuccessText; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }