public async Task <ApiResponse> Handle(EditHolidayDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var financialyear = await _dbContext.FinancialYearDetail.FirstOrDefaultAsync(x => x.IsDefault == true); if (request.HolidayType == (int)HolidayType.REPEATWEEKLYDAY) { var existrecord = await _dbContext.HolidayWeeklyDetails.Where(x => x.IsDeleted == false && x.OfficeId == request.OfficeId && x.FinancialYearId == financialyear.FinancialYearId).ToListAsync(); _dbContext.RemoveRange(existrecord); await _dbContext.SaveChangesAsync(); List <HolidayWeeklyDetails> holidayweeklylist = new List <HolidayWeeklyDetails>(); foreach (var hweeklylist in request.RepeatWeeklyDay) { HolidayWeeklyDetails list = new HolidayWeeklyDetails(); list.Day = hweeklylist.Day; list.OfficeId = (int)request.OfficeId; list.FinancialYearId = financialyear.FinancialYearId; list.ModifiedById = request.ModifiedById; list.ModifiedDate = request.ModifiedDate; list.IsDeleted = false; holidayweeklylist.Add(list); } await _dbContext.HolidayWeeklyDetails.AddRangeAsync(holidayweeklylist); await _dbContext.SaveChangesAsync(); List <HolidayDetails> holidaylist = new List <HolidayDetails>(); var hlist = await _dbContext.HolidayDetails.Where(x => x.IsDeleted == false && x.FinancialYearId == financialyear.FinancialYearId && x.OfficeId == request.OfficeId && x.HolidayType == (int)HolidayType.REPEATWEEKLYDAY).ToListAsync(); foreach (var h in hlist) { h.IsDeleted = true; h.ModifiedById = request.ModifiedById; h.ModifiedDate = request.ModifiedDate; holidaylist.Add(h); } //_uow.GetDbContext().HolidayDetails.UpdateRange(holidaylist); _dbContext.RemoveRange(holidaylist); await _dbContext.SaveChangesAsync(); List <HolidayDetails> holidaylist1 = new List <HolidayDetails>(); for (DateTime todaydate = financialyear.StartDate; todaydate <= financialyear.EndDate;) { HolidayDetails holiday = new HolidayDetails(); string day = todaydate.DayOfWeek.ToString(); foreach (var list in request.RepeatWeeklyDay) { if (list.Day == day) { holiday.HolidayName = "Weekly Off"; holiday.Date = todaydate; holiday.FinancialYearId = financialyear.FinancialYearId; holiday.OfficeId = request.OfficeId; holiday.HolidayType = request.HolidayType; holiday.CreatedById = request.CreatedById; holiday.CreatedDate = request.CreatedDate; holidaylist1.Add(holiday); } } todaydate = todaydate.AddDays(1); } await _dbContext.HolidayDetails.AddRangeAsync(holidaylist1); await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } else { var existrecord = await _dbContext.HolidayDetails.FirstOrDefaultAsync(x => x.HolidayId == request.HolidayId); if (existrecord != null) { existrecord.HolidayName = request.HolidayName; existrecord.Remarks = request.Remarks; existrecord.ModifiedById = request.ModifiedById; existrecord.ModifiedDate = request.ModifiedDate; existrecord.IsDeleted = false; _dbContext.HolidayDetails.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(AddEmployeeAppraisalMoreDetailsCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var recordList = await _dbContext.EmployeeEvaluation.Where(x => x.EmployeeId == request.EmployeeId && x.CurrentAppraisalDate.Date == DateTime.Now.Date).ToListAsync(); _dbContext.RemoveRange(recordList); List <EmployeeEvaluation> lst = new List <EmployeeEvaluation>(); List <StrongandWeakPoints> StrongList = new List <StrongandWeakPoints>(); List <StrongandWeakPoints> WeakList = new List <StrongandWeakPoints>(); foreach (var item in request.EmployeeEvaluationModelList) { EmployeeEvaluation obj = new EmployeeEvaluation(); obj.FinalResultQues1 = request.FinalResultQues1; obj.FinalResultQues2 = request.FinalResultQues2; obj.FinalResultQues3 = request.FinalResultQues3; obj.FinalResultQues4 = request.FinalResultQues4; obj.FinalResultQues5 = request.FinalResultQues5; obj.DirectSupervisor = request.DirectSupervisor; obj.CommentsByEmployee = request.CommentsByEmployee; obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.CurrentAppraisalDate = DateTime.Now; obj.EmployeeId = request.EmployeeId; lst.Add(obj); } await _dbContext.EmployeeEvaluation.AddRangeAsync(lst); foreach (var item in request.StrongPoints) { StrongandWeakPoints obj = new StrongandWeakPoints(); obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.CurrentAppraisalDate = DateTime.Now; obj.EmployeeId = request.EmployeeId; obj.Point = item; obj.Status = 1; // 1 for strong points StrongList.Add(obj); } await _dbContext.StrongandWeakPoints.AddRangeAsync(StrongList); foreach (var item in request.WeakPoints) { StrongandWeakPoints obj = new StrongandWeakPoints(); obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.CurrentAppraisalDate = DateTime.Now; obj.EmployeeId = request.EmployeeId; obj.Point = item; obj.Status = 2; // 2 for Weak points WeakList.Add(obj); } await _dbContext.StrongandWeakPoints.AddRangeAsync(WeakList); 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(EditEmployeeAppraisalMoreDetailsCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); try { var recordList = await _dbContext.EmployeeEvaluation.FirstOrDefaultAsync(x => x.EmployeeAppraisalDetailsId == request.EmployeeAppraisalDetailsId); if (recordList != null) { List <EmployeeEvaluationTraining> trainingList = new List <EmployeeEvaluationTraining>(); List <EmployeeAppraisalTeamMember> appraisalTeamMemberList = new List <EmployeeAppraisalTeamMember>(); List <StrongandWeakPoints> StrongList = new List <StrongandWeakPoints>(); List <StrongandWeakPoints> WeakList = new List <StrongandWeakPoints>(); var trainingData = await _dbContext.EmployeeEvaluationTraining.Where(x => x.EmployeeAppraisalDetailsId == request.EmployeeAppraisalDetailsId).ToListAsync(); _dbContext.RemoveRange(trainingData); foreach (var item in request.EmployeeEvaluationModelList) { EmployeeEvaluationTraining obj = new EmployeeEvaluationTraining(); obj.TrainingProgram = item.TrainingProgram; obj.Program = item.Program; obj.Participated = item.Participated; obj.CatchLevel = item.CatchLevel; obj.RefresherTrm = item.RefresherTrm; obj.OthRecommendation = item.OthRecommendation; obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.EmployeeAppraisalDetailsId = request.EmployeeAppraisalDetailsId; trainingList.Add(obj); } await _dbContext.EmployeeEvaluationTraining.AddRangeAsync(trainingList); //AppraisalTeamMemberList var appraisalTeamMemberData = await _dbContext.EmployeeAppraisalTeamMember.Where(x => x.EmployeeAppraisalDetailsId == request.EmployeeAppraisalDetailsId).ToListAsync(); _dbContext.RemoveRange(appraisalTeamMemberData); foreach (var item in request.EmployeeAppraisalTeamMemberList) { EmployeeAppraisalTeamMember obj = new EmployeeAppraisalTeamMember(); obj.EmployeeAppraisalDetailsId = request.EmployeeAppraisalDetailsId; //obj.EmployeeAppraisalTeamMemberId = item; obj.EmployeeId = item; obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; appraisalTeamMemberList.Add(obj); } await _dbContext.EmployeeAppraisalTeamMember.AddRangeAsync(appraisalTeamMemberList); recordList.FinalResultQues1 = request.FinalResultQues1; recordList.FinalResultQues2 = request.FinalResultQues2; recordList.FinalResultQues3 = request.FinalResultQues3; recordList.FinalResultQues4 = request.FinalResultQues4; recordList.FinalResultQues5 = request.FinalResultQues5; recordList.DirectSupervisor = request.DirectSupervisor; recordList.CommentsByEmployee = request.CommentsByEmployee; recordList.CurrentAppraisalDate = request.CurrentAppraisalDate; recordList.EmployeeId = request.EmployeeId; await _dbContext.SaveChangesAsync(); var empRecords = await _dbContext.StrongandWeakPoints.Where(x => x.IsDeleted == false && x.EmployeeAppraisalDetailsId == request.EmployeeAppraisalDetailsId).ToListAsync(); _dbContext.StrongandWeakPoints.RemoveRange(empRecords); foreach (var item in request.StrongPoints) { StrongandWeakPoints obj = new StrongandWeakPoints(); obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.CurrentAppraisalDate = DateTime.Now; obj.EmployeeId = request.EmployeeId; obj.Point = item; obj.Status = 1; // 1 for strong points obj.EmployeeAppraisalDetailsId = request.EmployeeAppraisalDetailsId; StrongList.Add(obj); } await _dbContext.StrongandWeakPoints.AddRangeAsync(StrongList); foreach (var item in request.WeakPoints) { StrongandWeakPoints obj = new StrongandWeakPoints(); obj.CreatedById = request.CreatedById; obj.CreatedDate = request.CreatedDate; obj.CurrentAppraisalDate = DateTime.Now; obj.EmployeeId = request.EmployeeId; obj.Point = item; obj.Status = 2; // 2 for Weak points obj.EmployeeAppraisalDetailsId = request.EmployeeAppraisalDetailsId; WeakList.Add(obj); } await _dbContext.StrongandWeakPoints.AddRangeAsync(WeakList); } await _dbContext.SaveChangesAsync(); response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = ex.Message; } return(response); }