public async Task <IActionResult> WholesalerEdit(string id) { ServiceReference_Wholesaler.Wholesaler w = await whole.findWholesalerByIdAsync(id); //ServiceReference_ContactPerson.ContactPerson c = await cp.findContactPersonbySalerIdAsync(id); ServiceReference_Country.Country[] lst_countries = await co.getAllCountryAsync(); WholesalerModel wm = new WholesalerModel() { coutries = lst_countries, WholesalerId = w.WholesalerId, Fullname = w.Fullname, Email = w.Email, Phone = w.Phone, AddressWS = w.AddressWS, CountryId = w.CountryId, Website = w.Website, StatusWS = w.StatusWS, //ContactPersonId = c.ContactPersonId, //CompanyName = c.Fullname, //CEmail = c.Email, //CPhone = c.Phone, //StatusCP = c.StatusCP }; ViewBag.flag = flag; ViewBag.message = message; flag = ""; message = ""; return(View(wm)); }
public async Task <IActionResult> WholesalerUpdate(WholesalerModel wm) { ServiceReference_Wholesaler.Wholesaler w = await whole.findWholesalerByIdAsync(wm.WholesalerId); //ServiceReference_ContactPerson.ContactPerson c = await cp.findContactPersonbySalerIdAsync(wm.WholesalerId); w.WholesalerId = wm.WholesalerId; w.Fullname = wm.Fullname; w.Email = wm.Email; w.Phone = wm.Phone; w.AddressWS = wm.AddressWS; w.CountryId = wm.CountryId; w.Website = wm.Website; w.StatusWS = wm.StatusWS; //c.ContactPersonId = wm.ContactPersonId; //c.WholesalerId = wm.WholesalerId; //c.Fullname = wm.CompanyName; //c.Email = wm.CEmail; //c.Phone = wm.CPhone; //c.StatusCP = wm.StatusCP; bool _boolean = await whole.updateWholesalerAsync(w); //bool _bool = await cp.updateContactPersonAsync(c); if (_boolean) { flag = "success"; message = "Update wholesaler success"; } else { flag = "error"; message = "Update wholesaler fail."; } return(RedirectToAction("WholesalerEdit/" + w.WholesalerId)); }
public async Task <IActionResult> WholesalerSave(WholesalerModel wm) { ServiceReference_Wholesaler.Wholesaler w = new ServiceReference_Wholesaler.Wholesaler(); ServiceReference_ContactPerson.ContactPerson c = new ServiceReference_ContactPerson.ContactPerson(); w.WholesalerId = wm.WholesalerId; w.Fullname = wm.Fullname; w.Email = wm.Email; w.Phone = wm.Phone; w.AddressWS = wm.AddressWS; w.CountryId = wm.CountryId; w.Website = wm.Website; w.StatusWS = wm.StatusWS; c.WholesalerId = await whole.getWholesalerIdAsync(wm.CountryId); c.Fullname = wm.CompanyName; c.Email = wm.CEmail; c.Phone = wm.CPhone; c.StatusCP = wm.StatusCP; bool _boolean = await whole.createWholesalerAsync(w); bool _bool = await cp.createContactPersonAsync(c); if (_boolean && _bool) { flag = "success"; message = "Add new wholesaler success"; } else { flag = "error"; message = "Add new wholesaler fail."; } return(RedirectToAction("WholesalerCreate")); }
public async Task <IActionResult> WholesalerCreate() { ServiceReference_Country.Country[] lst_countries = await co.getAllCountryAsync(); WholesalerModel im = new WholesalerModel() { coutries = lst_countries }; ViewBag.flag = flag; ViewBag.message = message; flag = ""; message = ""; return(View(im)); }
public async Task <IActionResult> saveAccount(WholesalerModel wholesaler) { var w = await ws.findWholesalerByIdAsync(wholesaler.WholesalerId); w.WholesalerId = wholesaler.WholesalerId; w.Fullname = wholesaler.Fullname; w.AddressWS = wholesaler.AddressWS; w.Website = wholesaler.Website; w.CountryId = wholesaler.CountryId; w.Phone = wholesaler.Phone; bool res = await ws.updateWholesalerAsync(w); string msg = res == true ? "success" : "error"; return(RedirectToAction("Account", new { msg = msg })); }
public async Task <IActionResult> Account(string msg) { ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User); _id = await getWholesalerId(user.Email); ViewBag.active = "account"; if (!String.IsNullOrEmpty(msg)) { ViewBag.msg = msg; } if (!String.IsNullOrEmpty(_id)) { ServiceReference_Wholesaler.Wholesaler w = await ws.findWholesalerByIdAsync(_id); ServiceReference_Country.Country[] lst_countries = await country.getAllCountryAsync(); ServiceReference_PurchaseOrder.PurchaseOrder[] orders = await po.findPurchaseOrderByWSIdAsync(_id); ServiceReference_Wholesaler.Wholesaler[] lst_ws = await ws.getAllWholesalerAsync(); WholesalerModel ws_model = new WholesalerModel { salerbyId = w, WholesalerId = w.WholesalerId, Fullname = w.Fullname, Email = w.Email, Phone = w.Phone, AddressWS = w.AddressWS, CountryId = w.CountryId, Website = w.Website, StatusWS = w.StatusWS, coutries = lst_countries, pOdersbyWSId = orders, wholesalers = lst_ws }; return(View(ws_model)); } return(View()); }
public async Task <IActionResult> WS_Invoice(string searchString, string podId) { ViewData["CurrentFilter"] = searchString; if (!String.IsNullOrEmpty(searchString)) { return(RedirectToAction("Category", "Home", new { searchString })); } if (!String.IsNullOrEmpty(_id)) { ServiceReference_Wholesaler.Wholesaler wsbyId = await ws.findWholesalerByIdAsync(_id); ServiceReference_Country.Country[] lst_countries = await country.getAllCountryAsync(); ServiceReference_PurchaseOrder.PurchaseOrder[] orders = await po.findPurchaseOrderByWSIdAsync(_id); ServiceReference_PurchaseOrderDetail.PurchaseOrderDetail[] orderdetails = null; ServiceReference_Invoice.Invoice[] invoices = null; if (!String.IsNullOrEmpty(podId)) { orderdetails = await pod.findPurchaseOrderDetailbypIdAsync(podId); invoices = await inc.findInvoicebyPurchaseIdAsync(podId); } WholesalerModel ws_model = new WholesalerModel { salerbyId = wsbyId, coutries = lst_countries, pOdersbyWSId = orders, pOderDetail = orderdetails, getInvoicebyWSId = invoices }; return(View(ws_model)); } return(View()); }