public int InsertLeaveAssigned(LeaveAssignedDTO data) { try { LeaveAssigned dataToInsert = new LeaveAssigned(); dataToInsert = LeaveAssignRequestFormatters.ConvertRespondentInfoFromDTO(data); LeaveAssignRequestFormatters.ConvertRespondentInfoToDTO(_unitOfWork.LeaveAssignedRepository.Create(dataToInsert)); return(1); } catch (Exception Ex) { return(0); } }
public static LeaveAssigned LeaveAsignedDTOtoLeaveAssign(LeaveAssignedDTOs Record) { LeaveAssigned result = new LeaveAssigned() { AssignedId = Record.AssignedId, AssignedDays = Record.AssignedDays, AssignedLeaveYearId = Record.AssignedLeaveYearId, AssignedRemarks = Record.AssignedRemarks, AssignEmpCode = Record.AssignEmpCode, AssignLeaveTypeId = Record.AssignLeaveTypeId, LeaveGainedMonth = Record.LeaveGainedMonth, }; return(result); }
public static LeaveAssignedDTOs LaveAssignToLeaveAssignDTO(LeaveAssigned Record) { LeaveAssignedDTOs result = new LeaveAssignedDTOs() { AssignedId = Record.AssignedId, AssignedDays = Convert.ToDecimal(Record.AssignedDays), AssignedLeaveYearId = Convert.ToInt32(Record.AssignedLeaveYearId), AssignedRemarks = Record.AssignedRemarks, AssignEmpCode = Record.AssignEmpCode, AssignLeaveTypeId = Record.AssignLeaveTypeId, LeaveGainedMonth = Convert.ToInt32(Record.LeaveGainedMonth), LeaveType = new LeaveType { IsPayable = Record.LeaveType.IsPayable, Gender = Record.LeaveType.Gender, HalfdayAllow = Record.LeaveType.HalfdayAllow, IsCashable = Record.LeaveType.IsCashable, IsTransferable = Record.LeaveType.IsTransferable, LeaveApplyBefore = Record.LeaveType.LeaveApplyBefore, LeaveCalculation = Record.LeaveType.LeaveCalculation, LeaveDeductionPriority = Record.LeaveType.LeaveDeductionPriority, LeaveRuleDetails = Record.LeaveType.LeaveRuleDetails, LeaveTypeId = Record.LeaveType.LeaveTypeId, LeaveTypeAssignment = Record.LeaveType.LeaveTypeAssignment, LeaveTypeDescription = Record.LeaveType.LeaveTypeDescription, LeaveTypeName = Record.LeaveType.LeaveTypeName, MaritalStatus = Record.LeaveType.MaritalStatus, MaxCashable = Record.LeaveType.MaxCashable, MaxTransferable = Record.LeaveType.MaxTransferable, NumberOfTime = Record.LeaveType.NumberOfTime, LeaveType1 = Record.LeaveType.LeaveType1, ProRataLeaveRatio = Record.LeaveType.ProRataLeaveRatio }, LeaveYear = new LeaveYear { YearId = Record.LeaveYear.YearId, LeaveAssigneds = Record.LeaveYear.LeaveAssigneds, YearCurrent = Record.LeaveYear.YearCurrent, YearEndDate = Record.LeaveYear.YearEndDate, YearEndDateNp = Record.LeaveYear.YearEndDateNp, YearName = Record.LeaveYear.YearName, YearStartDate = Record.LeaveYear.YearStartDate, YearStartDateNp = Record.LeaveYear.YearStartDateNp, } }; return(result); }
public LeaveAssignedDTO InsertLeaveAssigned(LeaveAssignedDTO lAsignDTO) { LeaveAssigned la = _unitOfWork.LeaveAssignedRepository.Create(LeaveRequestFormatter.ConvertRespondentInfoFromDTO(lAsignDTO)); return(LeaveRequestFormatter.ConvertRespondentInfoToDTO(la)); }
public static LeaveAssignedDTO ConvertRespondentInfoToDTO(LeaveAssigned leaveAssign) { Mapper.CreateMap <LeaveAssigned, LeaveAssignedDTO>(); return(Mapper.Map <LeaveAssigned, LeaveAssignedDTO>(leaveAssign)); }
public void CreateLeaveAssign(LeaveAssignedDTOs data) { int CurrentYear = _unitOfWork.LeaveYearRepository.All().Where(x => x.YearCurrent == true).Select(x => x.YearId).FirstOrDefault(); foreach (LeaveAssignedList Item in data.LeaveAssignedList) { if (Item.LeaveGainedMonth <= 1) { LeaveAssigned Record = _unitOfWork.LeaveAssignedRepository.Get(x => x.LeaveGainedMonth == Item.LeaveGainedMonth && x.AssignEmpCode == data.AssignEmpCode && x.AssignedLeaveYearId == CurrentYear && x.AssignLeaveTypeId == 1).FirstOrDefault(); if (Record != null) { Record.AssignedDays = Item.HomeLeaveBalance; _unitOfWork.LeaveAssignedRepository.Update(Record); } else { Record = new LeaveAssigned(); Record.AssignedDays = Item.HomeLeaveBalance; Record.AssignedLeaveYearId = CurrentYear; Record.LeaveGainedMonth = Item.LeaveGainedMonth; Record.AssignedRemarks = "0"; Record.AssignLeaveTypeId = 1; Record.AssignEmpCode = data.AssignEmpCode; _unitOfWork.LeaveAssignedRepository.Create(Record); } Record = _unitOfWork.LeaveAssignedRepository.Get(x => x.LeaveGainedMonth == Item.LeaveGainedMonth && x.AssignEmpCode == data.AssignEmpCode && x.AssignedLeaveYearId == CurrentYear && x.AssignLeaveTypeId == 2).FirstOrDefault(); if (Record != null) { Record.AssignedDays = Item.SickLeaveBalance; _unitOfWork.LeaveAssignedRepository.Update(Record); } else { Record = new LeaveAssigned(); Record.AssignedDays = Item.SickLeaveBalance; Record.AssignedLeaveYearId = CurrentYear; Record.LeaveGainedMonth = Item.LeaveGainedMonth; Record.AssignedRemarks = "0"; Record.AssignLeaveTypeId = 2; Record.AssignEmpCode = data.AssignEmpCode; _unitOfWork.LeaveAssignedRepository.Create(Record); } Record = _unitOfWork.LeaveAssignedRepository.Get(x => x.LeaveGainedMonth == Item.LeaveGainedMonth && x.AssignEmpCode == data.AssignEmpCode && x.AssignedLeaveYearId == CurrentYear && x.AssignLeaveTypeId == 3).FirstOrDefault(); if (Record != null) { Record.AssignedDays = Item.CasualLeaveBalance; _unitOfWork.LeaveAssignedRepository.Update(Record); } else { Record = new LeaveAssigned(); Record.AssignedDays = Item.CasualLeaveBalance; Record.AssignedLeaveYearId = CurrentYear; Record.LeaveGainedMonth = Item.LeaveGainedMonth; Record.AssignedRemarks = "0"; Record.AssignLeaveTypeId = 3; Record.AssignEmpCode = data.AssignEmpCode; _unitOfWork.LeaveAssignedRepository.Create(Record); } } else { LeaveAssigned Record = _unitOfWork.LeaveAssignedRepository.Get(x => x.LeaveGainedMonth == Item.LeaveGainedMonth && x.AssignEmpCode == data.AssignEmpCode && x.AssignedLeaveYearId == CurrentYear && x.AssignLeaveTypeId == 1).FirstOrDefault(); if (Record != null) { Record.AssignedDays = Item.HomeLeaveBalance; _unitOfWork.LeaveAssignedRepository.Update(Record); } else { Record = new LeaveAssigned(); Record.AssignedDays = Item.HomeLeaveBalance; Record.AssignedLeaveYearId = CurrentYear; Record.LeaveGainedMonth = Item.LeaveGainedMonth; Record.AssignedRemarks = "0"; Record.AssignLeaveTypeId = 1; Record.AssignEmpCode = data.AssignEmpCode; _unitOfWork.LeaveAssignedRepository.Create(Record); } } } }
public LeaveAssignedDTOs LeaveAssignCreateInfo(int empcode) { int CurrentYear = _unitOfWork.LeaveYearRepository.All().Where(x => x.YearCurrent == true).Select(x => x.YearId).FirstOrDefault(); List <LeaveAssigned> data = _unitOfWork.LeaveAssignedRepository.All().Where(x => x.AssignEmpCode == empcode && x.AssignedLeaveYearId == CurrentYear && x.LeaveGainedMonth == 0).ToList(); LeaveAssignedDTOs Result = new LeaveAssignedDTOs(); Result.HomeBalance = Convert.ToDecimal(data.Where(x => x.AssignLeaveTypeId == 1).Select(x => x.AssignedDays).FirstOrDefault()); Result.SickLeaveBalance = Convert.ToDecimal(data.Where(x => x.AssignLeaveTypeId == 2).Select(x => x.AssignedDays).FirstOrDefault()); Result.NepaliMonth = StaticSelectList.GetnepaliMonth().ToList(); decimal HomeLeaveBalance = 0; decimal SickLeaveBalance = 0; decimal CasualLeaveBalance = 0; List <LeaveAssignedList> AssignedList = new List <LeaveAssignedList>(); if (data.Count != 0) { LeaveAssignedList Item = new LeaveAssignedList(); Item.MonthName = "Previous year leave balance"; LeaveAssigned Leave = data.Where(x => x.AssignLeaveTypeId == 1).FirstOrDefault(); if (Leave != null) { HomeLeaveBalance = Convert.ToDecimal(Leave.AssignedDays); } else { HomeLeaveBalance = 0; } Leave = data.Where(x => x.AssignLeaveTypeId == 2).FirstOrDefault(); if (Leave != null) { SickLeaveBalance = Convert.ToDecimal(Leave.AssignedDays); } Item.HomeLeaveBalance = HomeLeaveBalance; Item.SickLeaveBalance = SickLeaveBalance; Item.CasualLeaveBalance = CasualLeaveBalance; Item.LeaveGainedMonth = 0; AssignedList.Add(Item); } else { LeaveAssignedList Item = new LeaveAssignedList(); Item.MonthName = "Previous year leave balance"; Item.HomeLeaveBalance = HomeLeaveBalance; Item.SickLeaveBalance = SickLeaveBalance; Item.CasualLeaveBalance = CasualLeaveBalance; Item.LeaveGainedMonth = 0; AssignedList.Add(Item); } List <CalenderMonth> Months = _unitOfWork.CalenderMonthRepository.All().OrderBy(x => x.MonthCode).ToList(); List <LeaveAssigned> Assigns = _unitOfWork.LeaveAssignedRepository.Get(x => x.AssignEmpCode == empcode && x.AssignedLeaveYearId == CurrentYear && x.LeaveGainedMonth != 0).ToList(); foreach (CalenderMonth Month in Months) { HomeLeaveBalance = 0; SickLeaveBalance = 0; CasualLeaveBalance = 0; LeaveAssignedList Item = new LeaveAssignedList(); Item.MonthName = Month.MonthNameNp; LeaveAssigned Leave = Assigns.Where(x => x.AssignLeaveTypeId == 1 && x.LeaveGainedMonth == Month.MonthCode).FirstOrDefault(); if (Leave != null) { HomeLeaveBalance = Convert.ToDecimal(Leave.AssignedDays); } Leave = Assigns.Where(x => x.AssignLeaveTypeId == 2 && x.LeaveGainedMonth == Month.MonthCode).FirstOrDefault(); if (Leave != null) { SickLeaveBalance = Convert.ToDecimal(Leave.AssignedDays); } Leave = Assigns.Where(x => x.AssignLeaveTypeId == 3 && x.LeaveGainedMonth == Month.MonthCode).FirstOrDefault(); if (Leave != null) { CasualLeaveBalance = Convert.ToDecimal(Leave.AssignedDays); } Item.MonthId = Month.MonthId; Item.HomeLeaveBalance = HomeLeaveBalance; Item.SickLeaveBalance = SickLeaveBalance; Item.CasualLeaveBalance = CasualLeaveBalance; Item.LeaveGainedMonth = Month.MonthCode; AssignedList.Add(Item); } Result.LeaveAssignedList = AssignedList; return(Result); }