public SellingModels ToSellingModels(SellingModel viewSellingModel) { return(new SellingModels() { Id = viewSellingModel.Id, ManagerName = viewSellingModel.ManagerName, ClientName = viewSellingModel.ClientName, Date = viewSellingModel.Date.Date, ProductName = viewSellingModel.ProductName, Cost = viewSellingModel.Cost }); }
public void AddNew(SellingModel sellingModel) { Selling selling = new Selling(); var manager = _unitOfWork.ManagerRepository.GetOne(x => x.Name == sellingModel.ManagerName); if (manager == null) { _unitOfWork.ManagerRepository.Add(new Manager() { Name = sellingModel.ManagerName }); var newManager = _unitOfWork.ManagerRepository.GetOne(x => x.Name == sellingModel.ManagerName); selling.ManagerId = newManager.Id; } else { selling.ManagerId = manager.Id; } var client = _unitOfWork.ClientRepository.GetOne(x => x.Name == sellingModel.ClientName); if (client == null) { _unitOfWork.ClientRepository.Add(new Client() { Name = sellingModel.ClientName }); var newClient = _unitOfWork.ClientRepository.GetOne(x => x.Name == sellingModel.ClientName); selling.ClientId = newClient.Id; } else { selling.ClientId = client.Id; } var product = _unitOfWork.ProductRepository.GetOne(x => x.Name == sellingModel.ProductName); if (product == null) { _unitOfWork.ProductRepository.Add(new Product() { Name = sellingModel.ProductName }); var newProduct = _unitOfWork.ProductRepository.GetOne(x => x.Name == sellingModel.ProductName); selling.ProductId = newProduct.Id; } else { selling.ProductId = product.Id; } selling.Date = sellingModel.Date; selling.Cost = sellingModel.Cost; _unitOfWork.SellingRepository.Add(selling); }
public void Update(SellingModel sellingModel) { var sellingEdit = _unitOfWork.SellingRepository.GetOne(x => x.Id == sellingModel.Id); _unitOfWork.ClientRepository.Update(new Client() { Id = sellingEdit.ClientId, Name = sellingModel.ClientName }); _unitOfWork.ProductRepository.Update(new Product() { Id = sellingEdit.ProductId, Name = sellingModel.ProductName }); sellingEdit.Date = sellingModel.Date; sellingEdit.Cost = sellingModel.Cost; _unitOfWork.SellingRepository.Update(sellingEdit); }
/// <summary> /// Sells a user-defined amount of bitcoin, bitcoin cash, litecoin or ethereum. /// https://developers.coinbase.com/api/v2?python#sell-resource /// </summary> /// <param name="client"></param> /// <param name="accountId"></param> /// <param name="sell"></param> /// <returns></returns> public static SellModel Sell(this Client client, String accountId, SellingModel sell) { var request = new RestRequest("/accounts/{account_id}/sells"); request.AddUrlSegment("account_id", accountId); request.Method = Method.POST; request.AddJsonBody2(sell); var rest = client.GetRestClient(request); var response = rest.Execute <GetResponseModel <SellModel> >(request); if (!response.IsSuccessful) { var error = JsonConvert.DeserializeObject <ResponseErrorModel>(response.Content); throw new Exception(error.Errors.First().Message); } return(response.Data.Data.First()); }