public DiscountService(IIOBalanceRepository <Discount> discount, IUserService userService) { this._discount = discount; this._userService = userService; this.discount = new Discount(); }
public bool SaveDiscount(DiscountDto discountDetails) { this.discount = discountDetails.DtoToEntity(); if (this._discount.Insert(this.discount).IsNull()) { return(false); } return(true); }
public bool UpdateDiscount(DiscountDto discountDetails) { var oldDiscountDetails = FindDiscountById(discountDetails.DiscountID); var updatedDiscountDetails = new IOBalanceEntity.Discount() { BranchID = discountDetails.BranchID, CreatedBy = oldDiscountDetails.CreatedBy, DateCreated = oldDiscountDetails.DateCreated, UpdatedBy = discountDetails.UpdatedBy, DateUpdated = System.DateTime.Now, DiscountID = oldDiscountDetails.DiscountID, DiscountPercentage = discountDetails.DiscountPercentage, IsActive = oldDiscountDetails.IsActive }; if (_discount.Update2(updatedDiscountDetails).IsNull()) { return(false); } return(true); }
public static IOBalanceEntity.Discount DtoToEntity(this DiscountDto dto) { IOBalanceEntity.Discount entity = null; if (!dto.IsNull()) { entity = new IOBalanceEntity.Discount() { DiscountID = 0, DiscountPercentage = dto.DiscountPercentage, BranchID = dto.BranchID, CreatedBy = dto.CreatedBy, DateCreated = System.DateTime.Now, UpdatedBy = dto.UpdatedBy, DateUpdated = dto.DateUpdated, IsActive = true }; } return(entity); }