public CommisionStructureLineVM GetCommisionStructureLineByID(int commisionStructureLineID) { try { tblCommisionStructureLine commisionStructureLineData = unitOfWork.TblCommisionStructureLineRepository.GetByID(commisionStructureLineID); CommisionStructureLineVM commisionStructureLineVM = new CommisionStructureLineVM(); commisionStructureLineVM.CommisionStructureLineID = commisionStructureLineData.ComStructLineID; commisionStructureLineVM.CommisionStructureID = commisionStructureLineData.ComStructID != null?Convert.ToInt32(commisionStructureLineData.ComStructID) : 0; if (commisionStructureLineVM.CommisionStructureID > 0) { commisionStructureLineVM.CommisionStructureName = commisionStructureLineData.tblCommisionStructureHeader.ComStructName; } commisionStructureLineVM.RateCategoryID = commisionStructureLineData.RateCategoryID != null?Convert.ToInt32(commisionStructureLineData.RateCategoryID) : 0; if (commisionStructureLineVM.RateCategoryID > 0) { commisionStructureLineVM.RateCategoryName = commisionStructureLineData.tblRateCategory.RateCategory; } commisionStructureLineVM.IsAgeConsider = commisionStructureLineData.IsAgeConsider; commisionStructureLineVM.AgeFrom = commisionStructureLineData.AgeFrom != null?Convert.ToInt32(commisionStructureLineData.AgeFrom) : 0; commisionStructureLineVM.AgeTo = commisionStructureLineData.AgeTo != null?Convert.ToInt32(commisionStructureLineData.AgeTo) : 0; commisionStructureLineVM.IsFixed = commisionStructureLineData.isFixed; commisionStructureLineVM.RateValue = commisionStructureLineData.RateValue != null?Convert.ToDouble(commisionStructureLineData.RateValue) : 0; commisionStructureLineVM.CreatedDate = commisionStructureLineData.CreatedDate != null?commisionStructureLineData.CreatedDate.ToString() : string.Empty; commisionStructureLineVM.ModifiedDate = commisionStructureLineData.ModifiedDate != null?commisionStructureLineData.ModifiedDate.ToString() : string.Empty; commisionStructureLineVM.CreatedBy = commisionStructureLineData.CreatedBy != null?Convert.ToInt32(commisionStructureLineData.CreatedBy) : 0; commisionStructureLineVM.ModifiedBy = commisionStructureLineData.ModifiedBy != null?Convert.ToInt32(commisionStructureLineData.ModifiedBy) : 0; return(commisionStructureLineVM); } catch (Exception ex) { throw; } }
public bool UpdateCommisionStructureLine(CommisionStructureLineVM commisionStructureLineVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblCommisionStructureLine commisionStructureLine = unitOfWork.TblCommisionStructureLineRepository.GetByID(commisionStructureLineVM.CommisionStructureLineID); commisionStructureLine.ComStructID = commisionStructureLineVM.CommisionStructureID; commisionStructureLine.RateCategoryID = commisionStructureLineVM.RateCategoryID; commisionStructureLine.IsAgeConsider = commisionStructureLineVM.IsAgeConsider; if (commisionStructureLine.IsAgeConsider) { commisionStructureLine.AgeFrom = commisionStructureLineVM.AgeFrom; commisionStructureLine.AgeTo = commisionStructureLineVM.AgeTo; } else { commisionStructureLine.AgeFrom = null; commisionStructureLine.AgeTo = null; } commisionStructureLine.isFixed = commisionStructureLineVM.IsFixed; commisionStructureLine.RateValue = commisionStructureLineVM.RateValue; commisionStructureLine.ModifiedDate = DateTime.Now; commisionStructureLine.ModifiedBy = commisionStructureLineVM.ModifiedBy; unitOfWork.TblCommisionStructureLineRepository.Update(commisionStructureLine); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public bool DeleteCommisionStructureLine(int commisionStructureLineID) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblCommisionStructureLine commisionStructureLine = unitOfWork.TblCommisionStructureLineRepository.GetByID(commisionStructureLineID); unitOfWork.TblCommisionStructureLineRepository.Delete(commisionStructureLine); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }