/// <summary> /// Create a new order /// </summary> /// <param name="orderCreateModel"></param> /// <returns></returns> public async Task <Guid> Create(OrderCreateModel orderCreateModel) { var customer = await _customerAppService.GetById(orderCreateModel.CustomerId); var company = await _companyAppService.GetById(orderCreateModel.CompanyId); var paymentType = await _paymentTypeAppService.GetById(orderCreateModel.PaymentMethodId); var address = await _addressAppService.GetById(orderCreateModel.AddressId); if (paymentType == null || customer == null || company == null || address == null) { throw new Exception("An error has occurred please try again."); } //Generate the order OrderDto model = new OrderDto(orderCreateModel, customer, company, address, paymentType); try { await _smtpEmailSender.SendAsync( to : "*****@*****.**", subject : "You have a new task!", body : $"A new task is assigned for you: <b>test</b>", isBodyHtml : true); } catch (Exception exception) { throw exception; } //We return the id so we can redirect to the orderitem page. return(await _repository.InsertAndGetIdAsync(ObjectMapper.Map <Models.Order>(model))); }
public async Task <PaymentTypeViewModel> PrepareEditModel(Guid id) { var type = await _appService.GetById(id); if (type == null) { throw new Exception("Not found"); } var model = new PaymentTypeViewModel() { DisplayOrder = type.DisplayOrder, TypeName = type.TypeName, Id = type.Id }; return(model); }