public async Task <ActionResult> SaveTransfer(ProductTransferModels model) { ProductTransfer productTransfer = new ProductTransfer() { warehouseOrigin = model.warehouseOrigin, warehouseDestiny = model.warehouseDestiny, observation = model.observation, status = "0", products = model.products, dateCreated = DateTime.Now.ToString("dd/MM/yyyy hh:mm") }; try { _productTransferServices = new ProductTransferServices(); var result = await _productTransferServices.SaveProductTransfer(productTransfer); if (result == null) { ModelState.AddModelError("", "Error al buscar el producto"); } } catch (System.Exception) { return(null); } return(RedirectToAction("getAll")); }
public ActionResult DeleteConfirmed(int id) { ProductTransfer productTransfer = _productTransferService.FindById(id); _productTransferService.DeleteProductTransfer(productTransfer); return(RedirectToAction("Index", "ProductTransfers")); }
public async Task <ProductTransfer> SaveProductTransfer(ProductTransfer productTransfer) { var _productTransfer = productTransfer; string url = "http://" + PATHSERVER + "/tshirt/producttransfer/save"; try { string json = JsonConvert.SerializeObject(_productTransfer); var content = new StringContent(json, Encoding.UTF8, "application/json"); Debug.WriteLine(json); HttpResponseMessage result = null; result = await client.PostAsync(url, content); if (result.IsSuccessStatusCode) { var x = await result.Content.ReadAsStringAsync(); _productTransfer = JsonConvert.DeserializeObject <ProductTransfer>(x); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } return(_productTransfer); }
public ActionResult Create([Bind(Include = "DateTransfered,FromBranchId,ToBranchId,UserId")] ProductTransferViewModel productTransferViewModel) { if (ModelState.IsValid) { MyIdentityDbContext db = new MyIdentityDbContext(); UserStore <MyIdentityUser> userStore = new UserStore <MyIdentityUser>(db); UserManager <MyIdentityUser> userManager = new UserManager <MyIdentityUser>(userStore); MyIdentityUser user = userManager.FindByName(HttpContext.User.Identity.Name); var productTransfer = new ProductTransfer() { //FromBranchId =1, //productTransferViewModel.FromBranchId, //ToBranchId= 2, //productTransferViewModel.ToBranchId, FromBranchId = productTransferViewModel.FromBranchId, ToBranchId = productTransferViewModel.ToBranchId, UserId = user.Id, DateTransfered = DateTime.Now }; _productTransferService.AddProductTransfer(productTransfer); return(RedirectToAction("Create", "ProductTransfers", new { id = productTransfer.ProductTransferId })); } return(View(productTransferViewModel)); }
public bool AddProductTransferLineItem(ProductTransfer productTransfer, ProductTransferLineItem item) { _unitOfWork.ProductTransferRepository.Edit(productTransfer); AddLineItemStock(item, productTransfer.ToBranchId); SubtractLineItemStock(item, productTransfer.FromBranchId); _unitOfWork.Save(); return(true); }
public ActionResult Edit([Bind(Include = "ProductTransferId,DateTransfered,FromBranchId,ToBranchId,UserId")] ProductTransfer productTransfer) { if (ModelState.IsValid) { _productTransferService.EditProductTransfer(productTransfer); return(RedirectToAction("Index")); } return(View(productTransfer)); }
public ActionResult DeleteTransfer(int id) { ProductTransfer productTransfer = _productTransferService.FindById(id); if (productTransfer.ProductTransferLineItems == null || productTransfer.ProductTransferLineItems.Count == 0) { _productTransferService.DeleteProductTransfer(productTransfer); } return(RedirectToAction("Index", "ProductTransfers")); }
public bool DeleteProductTransfer(ProductTransfer productTransfer) { if (productTransfer == null) { return(false); } _unitOfWork.ProductTransferRepository.Delete(productTransfer); _unitOfWork.Save(); return(true); }
public HttpResponseMessage Save(ProductTransfer productTransfer) { if (productTransfer != null) { var result = _productTransferRepository.Save(productTransfer); return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } }
public bool DeleteProductTransferLineItem(ProductTransfer productTransfer, ProductTransferLineItem lineItem) { //_unitOfWork.ProductTransferRepository.Edit(productTransfer); //SubtractLineItemStock(lineItem, productTransfer.FromBranchId); //_unitOfWork.Save(); //return true; _unitOfWork.ProductTransferLineItemRepository.Delete(lineItem); SubtractLineItemStock(lineItem, productTransfer.ToBranchId); AddLineItemStock(lineItem, productTransfer.FromBranchId); _unitOfWork.Save(); return(true); }
public bool AddProductTransfer(ProductTransfer productTransfer) { _unitOfWork.ProductTransferRepository.Add(productTransfer); if (productTransfer.ProductTransferLineItems != null) { foreach (var item in productTransfer.ProductTransferLineItems) { AddLineItemStock(item, productTransfer.ToBranchId); SubtractLineItemStock(item, productTransfer.FromBranchId); } } _unitOfWork.Save(); return(true); }
// GET: ProductTransfer/Details/5 public ActionResult Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductTransfer productTransfer = _productTransferService.FindById(id); if (productTransfer == null) { return(HttpNotFound()); } return(View(productTransfer)); }
public ProductTransfer Save(ProductTransfer productTransfer) { XmlWarehouseTranfer createXml = new XmlWarehouseTranfer(); int idTransferencia = 0; try { var _productTransfer = context.ProductTransfer.Add(productTransfer); context.SaveChanges(); productTransfer.Id = _productTransfer.Id; idTransferencia = _productTransfer.Id; foreach (ProductTransferDetail detail in productTransfer.products) { detail.ProductTransfer_Id = _productTransfer.Id; var _id = context.ProductTransferDetail.Add(detail); } context.SaveChanges(); //Update Amounts IWarehouseProductRepository _warehouseProductRepository = new WarehouseProductRepository(); foreach (ProductTransferDetail detail in productTransfer.products) { _warehouseProductRepository.UpdateAmountByCodes(productTransfer.WarehouseOrigin, productTransfer.WarehouseDestiny, detail.Quantity, detail.ProductCode); } //save XML string doc = createXml.Create(idTransferencia); return(productTransfer); } catch (Exception ex) { return(null); } }
private async void validateTransfer() { if (ProductTransferCollection.Count == 0) { await App.Current.MainPage.DisplayAlert("TSHIRT", "Debe ingresar uno o más productos a transferir", "OK"); } else { var answer = await App.Current.MainPage.DisplayAlert("TSHIRT", "Desea Guardar la solicitud?", "SI", "NO"); if (answer) { int pendiente = (int)ProductTransferEstatus.Pendiente; ProductTransfer productsTransfer = new ProductTransfer() { warehouseOrigin = _warehouseOriginSelect, warehouseDestiny = _warehouseDestinySelect, products = ProductTransferCollection.ToList(), dateCreated = DateTime.Now.ToString("dd/MM/yyyy hh:mm"), status = pendiente.ToString(), observation = Observation }; var result = await _productTransferServices.SaveProductTransfer(productsTransfer); if (result != null) { string id = string.Concat("00", result.Id.ToString()); id = id.Substring(id.Length - 3); await Application.Current.MainPage.Navigation.PushAsync(new Result(id)); } else { await App.Current.MainPage.DisplayAlert("TSHIRT", "Error al registrar la solicitud", "OK"); } } } }
protected override void Seed(MoencoPOSContext context) { var addresses = new List <Address> { new Address { AddressId = 1, LandLineNo = "+251111123456", CellPhoneNo = "+251911123456", State = "Afar", City = "Semera", StreetNo = "12345", HouseNo = "123" }, new Address { AddressId = 2, LandLineNo = "+555555555555", CellPhoneNo = "+666666666666", State = "Amhara", City = "Bahirdar", StreetNo = "44444", HouseNo = "555" }, }; addresses.ForEach(s => context.Addresses.Add(s)); context.SaveChanges(); var branches = new List <Branch> { new Branch { BranchName = "Main", BranchLocation = "Addis Ababa", BranchDescription = "Country Main Branch" }, new Branch { BranchName = "South Branch", BranchLocation = "Awassa", BranchDescription = "SNNP Branch in Awassa" } }; branches.ForEach(s => context.Branches.Add(s)); context.SaveChanges(); var customers = new List <Customer> { new Customer { FirstName = "Tewodros", LastName = "Afro", Address = "Arat Killo", TelephoneNo = "123456789", TIN = "123456789", VATNumber = "123456789", Trusted = true }, new Customer { FirstName = "Tilahun", LastName = "Gessesse", Address = "Arat Killo", TelephoneNo = "123456789", TIN = "123456789", VATNumber = "123456789", Trusted = true } }; customers.ForEach(s => context.Customers.Add(s)); context.SaveChanges(); var salesInvoices = new List <SalesInvoice> { new SalesInvoice { SalesInvoiceId = 1, CustomerId = 1, BranchId = 1, SalesType = 0, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09"), ReferenceNo = "ABC-123" }, new SalesInvoice { SalesInvoiceId = 2, CustomerId = 2, BranchId = 2, SalesType = 1, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09"), ReferenceNo = "XYZ-123" } }; salesInvoices.ForEach(s => context.SalesInvoices.Add(s)); context.SaveChanges(); var categories = new List <Category> { new Category { CategoryName = "Car", CategoryDescription = "Toyota Cars." }, new Category { CategoryName = "Tyres", CategoryDescription = "Tyre for diffrent model Toyota Cars." } }; categories.ForEach(s => context.Categories.Add(s)); context.SaveChanges(); var productcs = new List <Productc> { new Productc { ProductName = "Toyota Vitz", ProductDescription = "Toyota Vitz 2014", Model = "Vitz 2014", UnitOfMeasure = "Pcs", UnitCost = 200000.00M, UnitPrice = 250000.00M, CategoryId = 1 }, new Productc { ProductName = "Toyota Yaris", ProductDescription = "Toyota Yaris 2012", Model = "Yaris 2012", UnitOfMeasure = "Pcs", UnitCost = 350000.00M, UnitPrice = 400000.00M, CategoryId = 1 } }; productcs.ForEach(s => context.Productcs.Add(s)); context.SaveChanges(); var stocks = new List <Stock> { new Stock { BranchId = 1, ProductId = 1, Quantity = 5 }, new Stock { BranchId = 1, ProductId = 2, Quantity = 3 } }; stocks.ForEach(s => context.Stocks.Add(s)); context.SaveChanges(); var receiveInvoice = new ProductReceive { UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", BranchId = 1, DateReceived = DateTime.Parse("2017-12-09") }; var receiveLineItems = new List <ProductReceiveLineItem> { new ProductReceiveLineItem { ProductId = 1, Quantity = 1, UnitCost = 200000.00M }, new ProductReceiveLineItem { ProductId = 2, Quantity = 1, UnitCost = 350000.00M } }; receiveInvoice.ProductReceiveLineItems = receiveLineItems; context.ProductReceives.Add(receiveInvoice); context.SaveChanges(); var transferInvoice = new ProductTransfer { UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", FromBranchId = 1, ToBranchId = 2, DateTransfered = DateTime.Parse("2017-12-09") }; var transferLineItems = new List <ProductTransferLineItem> { new ProductTransferLineItem { ProductId = 1, Quantity = 1 }, new ProductTransferLineItem { ProductId = 2, Quantity = 1 } }; transferInvoice.ProductTransferLineItems = transferLineItems; context.ProductTransfers.Add(transferInvoice); context.SaveChanges(); }
public bool EditProductTransfer(ProductTransfer productTransfer) { _unitOfWork.ProductTransferRepository.Edit(productTransfer); _unitOfWork.Save(); return(true); }
protected override void Seed(REERPContext context) { var addresses = new List <Address> { new Address { AddressId = 1, LandLineNo = "+251111123456", CellPhoneNo = "+251911123456", State = "Afar", City = "Semera", StreetNo = "12345", HouseNo = "123" }, new Address { AddressId = 2, LandLineNo = "+555555555555", CellPhoneNo = "+666666666666", State = "Amhara", City = "Bahirdar", StreetNo = "44444", HouseNo = "555" }, }; addresses.ForEach(s => context.Addresses.Add(s)); context.SaveChanges(); var branches = new List <Branch> { new Branch { BranchName = "Main", BranchLocation = "Addis Ababa", BranchDescription = "Country Main Branch" }, new Branch { BranchName = "South Branch", BranchLocation = "Awassa", BranchDescription = "SNNP Branch in Awassa" } }; branches.ForEach(s => context.Branches.Add(s)); context.SaveChanges(); var customers = new List <Customer> { new Customer { FirstName = "Tewodros", LastName = "Afro", Address = "Arat Killo", TelephoneNo = "123456789", TIN = "123456789", VATNumber = "123456789", Trusted = true }, new Customer { FirstName = "Tilahun", LastName = "Gessesse", Address = "Arat Killo", TelephoneNo = "123456789", TIN = "123456789", VATNumber = "123456789", Trusted = true } }; customers.ForEach(s => context.Customers.Add(s)); context.SaveChanges(); var salesInvoices = new List <SalesInvoice> { new SalesInvoice { SalesInvoiceId = 1, CustomerId = 1, BranchId = 1, SalesType = 0, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09") }, new SalesInvoice { SalesInvoiceId = 2, CustomerId = 2, BranchId = 2, SalesType = 1, UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", DateSold = DateTime.Parse("2016-10-09") } }; salesInvoices.ForEach(s => context.SalesInvoices.Add(s)); context.SaveChanges(); var categories = new List <Category> { new Category { CategoryName = "Brandy", CategoryDescription = "Distilled From: Fruit. Primarily grapes, though apple, apricot, cherry, peach, and other fruits" }, new Category { CategoryName = "Gin", CategoryDescription = "Distilled From: Neutral grains such as barley, corn, rye, and wheat. Flavored with a variety of botanicals, which vary by brand" }, new Category { CategoryName = "Rum", CategoryDescription = "Distilled From: Sugar. Either molasses or pure sugar cane" }, new Category { CategoryName = "Tequila", CategoryDescription = "Agave plant" }, new Category { CategoryName = "Vodka", CategoryDescription = "Distilled From: Neutral grain (rye, corn, wheat, etc.) or potato. Some are distilled from beets, grapes, and other bases" }, new Category { CategoryName = "Whiskey", CategoryDescription = "Distilled From: Neutral grain (rye, corn, wheat, etc.) or potato. Some are distilled from beets, grapes, and other bases" } }; categories.ForEach(s => context.Categories.Add(s)); context.SaveChanges(); var productcs = new List <Productc> { new Productc { ProductcId = "001", ProductName = "Courvoisier - V.S", ProductDescription = "750 ml ", Model = "", UnitOfMeasure = "Pcs", UnitCost = 58.00M, UnitPrice = 58.00M, CategoryId = 1 }, new Productc { ProductcId = "002", ProductName = "Courvoisier - V.S.O.P", ProductDescription = "750 ml ", Model = "", UnitOfMeasure = "Pcs", UnitCost = 89.00M, UnitPrice = 89.00M, CategoryId = 1 }, new Productc { ProductcId = "003", ProductName = "Courvoisier - X.O. IMPERIAL", ProductDescription = "750 ml ", Model = "", UnitOfMeasure = "Pcs", UnitCost = 240.00M, UnitPrice = 240.00M, CategoryId = 1 } }; productcs.ForEach(s => context.Productcs.Add(s)); context.SaveChanges(); var stocks = new List <Stock> { new Stock { BranchId = 1, ProductcId = "001", Quantity = 100 }, new Stock { BranchId = 1, ProductcId = "002", Quantity = 100 }, new Stock { BranchId = 1, ProductcId = "003", Quantity = 100 } }; stocks.ForEach(s => context.Stocks.Add(s)); context.SaveChanges(); var receiveInvoice = new ProductReceive { UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", BranchId = 1, DateReceived = DateTime.Parse("2017-12-09") }; var receiveLineItems = new List <ProductReceiveLineItem> { new ProductReceiveLineItem { ProductId = "001", Quantity = 25, UnitCost = 58.00M }, new ProductReceiveLineItem { ProductId = "002", Quantity = 25, UnitCost = 89.00M }, new ProductReceiveLineItem { ProductId = "003", Quantity = 55, UnitCost = 240.00M } }; receiveInvoice.ProductReceiveLineItems = receiveLineItems; context.ProductReceives.Add(receiveInvoice); context.SaveChanges(); var transferInvoice = new ProductTransfer { UserId = "98f74499-a614-4373-aacd-5eec5b46ef95", FromBranchId = 1, ToBranchId = 2, DateTransfered = DateTime.Parse("2017-12-09") }; var transferLineItems = new List <ProductTransferLineItem> { new ProductTransferLineItem { ProductId = "001", Quantity = 25 }, new ProductTransferLineItem { ProductId = "002", Quantity = 25 }, new ProductTransferLineItem { ProductId = "003", Quantity = 25 } }; transferInvoice.ProductTransferLineItems = transferLineItems; context.ProductTransfers.Add(transferInvoice); context.SaveChanges(); }