public LogicResult <ProductTypeDTO> GetById(Guid id) { try { var entity = _productTypeBusinessLogic.GetById(id); return(LogicResult <ProductTypeDTO> .Succeed(entity)); } catch (Exception exception) { return(LogicResult <ProductTypeDTO> .Failure(exception)); } }
public LogicResult <IEnumerable <ProductTypeDTO> > GetAll() { try { var users = _productTypeBusinessLogic.GetAll(); return(LogicResult <IEnumerable <ProductTypeDTO> > .Succeed(users)); } catch (Exception exception) { return(LogicResult <IEnumerable <ProductTypeDTO> > .Failure(exception)); } }
public LogicResult <PaymentDetail> CalculatePrice(PriceDetail priceDetail) { var paymentDetailResult = _priceCalculationService.CalculatePrice(priceDetail); if (paymentDetailResult.IsSucceed) { return(LogicResult <PaymentDetail> .Succeed(paymentDetailResult.Data)); } else { return(LogicResult <PaymentDetail> .Failure(Validation.UnSuccessfullOperation)); } }
public LogicResult <PaymentDetail> CalculatePrice(PriceDetail priceDetail) { try { var calculation = this.GetCalculation(priceDetail.Type); var paymentDetail = calculation.CalculatePrice(priceDetail); return(LogicResult <PaymentDetail> .Succeed(paymentDetail)); } catch (Exception exception) { return(LogicResult <PaymentDetail> .Failure(exception)); } }
public LogicResult <IEnumerable <ProductDTO> > GetByTypeId(Guid typeId) { var result = _productService.GetAll(); if (result.IsSucceed) { var products = result.Data.Where(m => m.TypeId == typeId); return(LogicResult <IEnumerable <ProductDTO> > .Succeed(products)); } else { return(LogicResult <IEnumerable <ProductDTO> > .Failure(result.FailureResult.ToArray())); } }
public LogicResult <UserDTO> Login(UserLoginModel model) { var result = _userService.GetAll(); if (result.IsSucceed) { var user = result.Data.FirstOrDefault(m => m.Email == model.Email); if (user != null) { var response = Crypto.VerifyHashedPassword(user.Password, model.Password) ? LogicResult <UserDTO> .Succeed(user) : LogicResult <UserDTO> .Failure(Resources.Validation.InvalidEmailOrPassword); return(response); } else { return(LogicResult <UserDTO> .Failure(Resources.Validation.InvalidEmailOrPassword)); } } else { return(LogicResult <UserDTO> .Failure(Resources.Validation.UnSuccessfullOperation)); } }
public LogicResult <IEnumerable <ProductCartModel> > GetProductsByUser(Guid userId) { try { var userProducts = from userToProduct in _userToProductQueryService.GetAll() join product in _productQueryService.GetAll() on userToProduct.ProductId equals product.Id join productType in _productTypeServiceFacade.Data on product.TypeId equals productType.Id where userToProduct.UserId == userId select new ProductCartModel { Day = userToProduct.Day, UserId = userToProduct.UserId, Point = userToProduct.Point, Id = userToProduct.ProductId, PaymentDetail = SerializerHelper.DeserializeObject <PaymentDetail>(userToProduct.PaymentDetail), Name = product.Name, Type = productType.Type }; return(LogicResult <IEnumerable <ProductCartModel> > .Succeed(userProducts)); } catch { return(LogicResult <IEnumerable <ProductCartModel> > .Failure(Validation.UnSuccessfullOperation)); } }