private Buyer GetEntityByModel(BuyerModel model) { if (model == null) { return(null); } Buyer entity = new Buyer(); entity.Id = model.Id; entity.Name = model.Name; entity.SOBId = SessionHelper.SOBId; entity.StartDate = model.StartDate; entity.EndDate = model.EndDate; if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; entity.CompanyId = AuthenticationHelper.CompanyId.Value; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; entity.CompanyId = model.CompanyId; } entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
public BuyerModel GetById(int?id) { var body = ""; BuyerModel BuyerModelById = ServerResponse.Invoke <BuyerModel>("api/buyer/getDetail?id=" + id, body, "GET"); return(BuyerModelById); }
public BuyerModel Edit(BuyerModel buyerModel) { var body = JsonConvert.SerializeObject(buyerModel); BuyerModel BuyerEdit = ServerResponse.Invoke <BuyerModel>("api/buyer/edit?id=" + buyerModel.Id, body, "POST"); return(BuyerEdit); }
public BuyerModel Create(BuyerModel buyerModel) { var body = JsonConvert.SerializeObject(buyerModel); BuyerModel BuyerCreate = ServerResponse.Invoke <BuyerModel>("api/buyer/create", body, "Post"); return(BuyerCreate); }
public ActionResult Create([Bind(Include = "Id,PhoneNumber,ImagePath,FirstName,LastName,Password,ConfirmPassword,StoreName,BusinessAddress,IsActive,IsApproved")] BuyerModel buyerModel, HttpPostedFileBase file) { UserModel user = new UserModel(); if (ModelState.IsValid) { if (file != null) { string filename = Guid.NewGuid().ToString("N") + file.FileName; file.SaveAs(HttpContext.Server.MapPath("~/Images/") + filename); buyerModel.ImagePath = filename; } user.PhoneNumber = buyerModel.PhoneNumber; user.FirstName = buyerModel.FirstName; user.LastName = buyerModel.LastName; user.Type = "Buyer"; user.Password = buyerModel.Password; user.ConfirmPassword = buyerModel.ConfirmPassword; user.StoreName = buyerModel.StoreName; user.Address = buyerModel.BusinessAddress; user.ImagePath = buyerModel.ImagePath; //db.BuyerModels.Add(buyerModel); db.UserModels.Add(user); db.SaveChanges(); //return RedirectToAction("Index"); } Session["UserModel"] = user; return(RedirectToAction("Login")); //return View(buyerModel); }
public BuyerModel Delete(BuyerModel buyerModel) { var body = JsonConvert.SerializeObject(buyerModel); BuyerModel BuyerDelete = ServerResponse.Invoke <BuyerModel>("api/buyer/Delete?id=" + buyerModel.Id, body, "POST"); return(BuyerDelete); }
public IBuyer CurrentUser() { IBuyer buyer = new BuyerModel(); try { using (SQLiteConnection Connection = new SQLiteConnection(SqliteConnectionString.ConnectionString)) { Connection.Open(); string Querry = "Select * FROM Buyers Where ID = 1"; using (var command = new SQLiteCommand(Querry, Connection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { buyer.ID = Convert.ToInt64(reader["id"]); buyer.FullName = reader["fio"].ToString(); buyer.DateOfBirthdate = reader["DateOfBirthday"].ToString(); buyer.Phone = reader["phone"].ToString(); buyer.MoneyCount = Convert.ToInt64(reader["MoneyCount"]); } } } } } catch (Exception e) { throw e.FromMethod("Не удалось получить пользователей из БД", MethodBase.GetCurrentMethod()); } return(buyer); }
public List <BuyerModel> AllBuyers(BuyerModel objbuyer) { List <BuyerModel> Allbuyers = new List <BuyerModel>(); using (ShopDevEntities db = new ShopDevEntities()) { try { var res = from buyer in db.Buyers where (buyer.BuyerName.Contains(objbuyer.BuyerName) || buyer.CustomerCode == objbuyer.CustomerCode) || (string.IsNullOrEmpty(objbuyer.BuyerName) && objbuyer.CustomerCode == null) select buyer; foreach (var seller in res) { BuyerModel sellerModel = new BuyerModel(); seller.CopyProperties(sellerModel); Allbuyers.Add(sellerModel); } } catch (Exception ex) { } return(Allbuyers); } }
public ActionResult DeleteConfirmed(int id) { BuyerModel buyerModel = db.BuyerModels.Find(id); db.BuyerModels.Remove(buyerModel); db.SaveChanges(); return(RedirectToAction("Index")); }
private static void MakePayment(IWebDriver driver, BuyerModel buyer) { PlaySound(); Thread.Sleep(9000); var postcode = driver.FindElement(By.XPath("//*[@data-element='ButtonText']")); //postcode.Click(); //Console.WriteLine(""); }
private string Save(BuyerModel model) { Buyer entity = GetEntityByModel(model); return(model.Id > 0 ? service.Update(entity) : service.Insert(entity)); }
public ActionResult Create(BuyerModel model) { if (ModelState.IsValid) { Save(model); return(RedirectToAction("Index")); } return(View(model)); }
private static void EnterDetails(IWebDriver driver, BuyerModel buyer) { try { var title = driver.FindElement(By.XPath("//*[@name='d-title']")); Thread.Sleep(TimeSpan.FromMilliseconds(200)); title.SendKeys(Keys.Tab); Thread.Sleep(TimeSpan.FromMilliseconds(200)); title.SendKeys(Keys.Tab); Thread.Sleep(TimeSpan.FromMilliseconds(200)); title.SendKeys(Keys.ArrowDown); Thread.Sleep(TimeSpan.FromMilliseconds(200)); title.SendKeys(Keys.ArrowDown); title.SendKeys(Keys.Enter); title.SendKeys(Keys.Tab); var fname = driver.FindElement(By.XPath("//*[@name='fname']")); fname.SendKeys(buyer.Forename); var lname = driver.FindElement(By.XPath("//*[@name='lname']")); lname.SendKeys(buyer.Surname); var mobile = driver.FindElement(By.XPath("//*[@name='country-code phone']")); mobile.SendKeys(buyer.MobileNumber); var address = driver.FindElement(By.XPath("//*[@name='address']")); address.SendKeys(buyer.AddressLine1); var city = driver.FindElement(By.XPath("//*[@name='city']")); city.SendKeys(buyer.City); var postcode = driver.FindElement(By.XPath("//*[@name='zip']")); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(Keys.Backspace); postcode.SendKeys(buyer.Postcode); var act = new Actions(driver); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Tab).Build().Perform(); act.SendKeys(Keys.Enter).Build().Perform(); } catch (Exception e) { Console.WriteLine($"Couldn't fill out delivery details: {e.Message}", e); throw; } }
public ActionResult Edit(string id) { BuyerModel model = new BuyerModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value)); if (model == null) { return(HttpNotFound()); } return(View(model)); }
public ActionResult DeleteConfirmed(BuyerModel buyer) { if (buyer.Id > 0) { BuyerModel BuyerDelete = Services.BuyerService.Delete(buyer); TempData["Success"] = "Data Deleted successfully!"; return(RedirectToAction("Index", "Buyer")); } return(View(buyer)); }
public ActionResult Edit(BuyerModel buyer) { if (ModelState.IsValid) { BuyerModel BuyerEdit = Services.BuyerService.Edit(buyer); TempData["Success"] = "Data Saved Successfully!"; return(RedirectToAction("Index", "Buyer")); } return(View(buyer)); }
public ActionResult Edit([Bind(Include = "ID,LastName,FirstName,JoinDate,InProcess")] BuyerModel buyerModel) { if (ModelState.IsValid) { db.Entry(buyerModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(buyerModel)); }
public IActionResult DisplayReceiveInformation([FromBody] BuyerModel buyerModel) // 查看买家所有收货地址 { List <ReceiveInformation> receiveInformation = new List <ReceiveInformation>(); receiveInformation = receiveInformationService.GetReceiveInformation(buyerModel.BuyerId); string str = JsonConvert.SerializeObject(receiveInformation); return(new ContentResult { Content = str, ContentType = "application/json" }); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BuyerModel BuyerModelById = Services.BuyerService.GetById(id); return(View(BuyerModelById)); }
public Task <bool> CreateBuyer([FromBody] BuyerModel buyer) { try { FakeDatabase.buyers.Add(buyer); return(Task.FromResult(true)); } catch { return(Task.FromResult(false)); } }
public static void BuyProduct(ProductModel product, IWebDriver driver, BuyerModel buyer) { NavigateToLink(product, driver); ClickAddToBasket(driver); ClickContinueToCheckout(driver); GoToCheckout(driver); WhereToDeliver(driver); SelectDeliveryDate(driver); EnterEmailAndCheckoutAsGuest(driver); EnterDetails(driver, buyer); MakePayment(driver, buyer); }
public ActionResult Create(BuyerModel buyer) { var errors = ModelState.Values.SelectMany(v => v.Errors); if (ModelState.IsValid) { buyer.IsActive = true; BuyerModel BuyerCreate = Services.BuyerService.Create(buyer); TempData["Success"] = "Data Saved Successfully!"; return(RedirectToAction("Index", "Buyer")); } return(View(buyer)); }
//前后端交互 public JsonResult GetPhonePasswdById([FromBody] BuyerModel buyerModel) { string buyerPasswd = service1.displayPasswd(buyerModel.BuyerId); string buyerPhone = service1.displayPhone(buyerModel.BuyerId); JsonData jsondata = new JsonData(); if (buyerPasswd != null && buyerPhone != null) { jsondata["buyerPasswd"] = buyerPasswd; jsondata["buyerPhone"] = buyerPhone; } return(Json(jsondata.ToJson()));//这玩意是个string }
// GET: BuyerModels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BuyerModel buyerModel = db.BuyerModels.Find(id); if (buyerModel == null) { return(HttpNotFound()); } return(View(buyerModel)); }
public JsonResult DisplayBuyerInfo([FromBody] BuyerModel buyerModel) { Buyer buyer = service2.SearchByID(buyerModel.BuyerId); JsonData jsondata = new JsonData(); if (buyer != null) { jsondata["buyerNickname"] = buyer.Nickname; jsondata["buyerPhone"] = buyer.Phone; jsondata["buyerGender"] = buyer.Gender; jsondata["buyerBirth"] = buyer.DateBirth.ToString(); jsondata["buyerUrl"] = buyer.Url; } return(Json(jsondata.ToJson()));//这玩意是个string }
public IActionResult DisplayFavorites([FromBody] BuyerModel buyerModel) // 查看关注商品 { List <FavoriteProductView> favorites = new List <FavoriteProductView>(); favorites = favoriteProductService.getFavoriteProduct(buyerModel.BuyerId); foreach (var favorite in favorites) { favorite.CommodityImg = "../.." + favorite.CommodityImg; } string str = JsonConvert.SerializeObject(favorites); return(new ContentResult { Content = str, ContentType = "application/json" }); }
public ActionResult Edit([Bind(Include = "Id,PhoneNumber,ImagePath,FirstName,LastName,Password,ConfirmPassword,StoreName,BusinessAddress,IsActive,IsApproved")] BuyerModel buyerModel, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { string filename = Guid.NewGuid().ToString("N") + file.FileName; file.SaveAs(HttpContext.Server.MapPath("~/Images/") + filename); buyerModel.ImagePath = filename; } db.Entry(buyerModel).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); return(RedirectToAction("Index", "Home")); } return(View(buyerModel)); }
public ActionResult Create([Bind(Include = "ID,LastName,FirstName,JoinDate,InProcess")] BuyerModel buyerModel) { try { if (ModelState.IsValid) { db.BuyerModels.Add(buyerModel); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { Console.WriteLine(ex.Message); ModelState.AddModelError("", "Unable to save changes."); } return(View(buyerModel)); }
public ActionResult Create(BuyerModel model) { ResponseJson response = new ResponseJson(); try { if (!ModelState.IsValid) { return(Json(Globals.SetValidationError(ModelState))); } UpdatedInfoModel updatedInfo = new UpdatedInfoModel() { Comment = "Seller Created", Type = 1, UpdatedTime = DateTime.Now, UserId = CurrentUser.Id }; using (AppDB db = new AppDB()) { DAL.Buyer seller = new DAL.Buyer() { CreatedBy = CurrentUser.Id, Description = model.Description, Id = Guid.NewGuid(), Name = model.Name, CreatedAt = DateTime.Now, Phone = model.Phone, Email = model.Email, Address = model.Address, UpdateInfo = new JavaScriptSerializer().Serialize(updatedInfo) }; db.Buyers.Add(seller); db.SaveChanges(); response.Data = new { Id = seller.Id, Name = seller.Name }; //EmailSender.SendToCHWUser(model.Email, login, login, model.Surname, "Sector Executive Officer"); } } catch (Exception ex) { response.IsError = true; response.Id = -6; } return(Json(response)); }
public BuyerViewModel GetBuyerInfo(long?buyerId) { BuyerViewModel buyermodel = new BuyerViewModel(); using (ShopDevEntities db = new ShopDevEntities()) { try { var buyercustomerInfo = db.Buyers.Where(m => m.BuyerID == buyerId).FirstOrDefault(); var lstproducts = db.BuyerProducts.Where(m => m.BuyerID == buyerId).ToList(); var AllInstallments = db.BuyerInstallments.Where(m => m.BuyerID == buyerId).ToList(); BuyerModel bbModel = new BuyerModel(); buyercustomerInfo.CopyProperties(bbModel); List <BuyerProductModel> lstcsproducts = new List <BuyerProductModel>(); foreach (var cusprod in lstproducts) { BuyerProductModel objcsproduct = new BuyerProductModel(); cusprod.CopyProperties(objcsproduct); lstcsproducts.Add(objcsproduct); } List <BuyerInstallmentModel> lstInstallments = new List <BuyerInstallmentModel>(); foreach (var cusprod in AllInstallments) { BuyerInstallmentModel objcsproduct = new BuyerInstallmentModel(); cusprod.CopyProperties(objcsproduct); lstInstallments.Add(objcsproduct); } buyermodel.buyer = bbModel; buyermodel.productInfo = new BuyerProductModel(); buyermodel.LstProducts = new List <BuyerProductModel>(); buyermodel.LstProducts.AddRange(lstcsproducts); buyermodel.Installments = new BuyerInstallmentModel(); buyermodel.LstInstallments = new List <BuyerInstallmentModel>(); buyermodel.LstInstallments.AddRange(lstInstallments); } catch (Exception) { } } return(buyermodel); }