/// <summary> /// Method for removing SellOffer entity from database /// </summary> /// <param name="sellOffer">SellOffer entity to remove</param> public void Remove(SellOffer sellOffer) { _context.Remove(sellOffer); var watch = Stopwatch.StartNew(); _context.SaveChanges(); LastOperationTime = (int)watch.ElapsedMilliseconds; }
public ActionResult AddSellOffer(SellOffer Offer) { if (Offer.Title == null) { ModelState.AddModelError("Offer.Title", "Hay que poner un titulo!"); } if (Offer.ClientUserName == null) { ModelState.AddModelError("Offer.ClientUserName", "Hay que escoger un cliente!"); } if (Offer.PropertyId == 0) { ModelState.AddModelError("Offer.PropertyId", "Hay que escoger una propiedad!"); } if (!ModelState.IsValid) { return(View(new SellOfferViewModels { Offer = new SellOffer(), Agents = unitOfWork.Repository <Agent>().ToList(), Clients = unitOfWork.Repository <Client>().ToList(), Properties = unitOfWork.Repository <Property>().ToList(), Tags = unitOfWork.Repository <Tag>().ToList() })); } unitOfWork.Repository <SellOffer>().Add(new Domain.SellOffer() { Agent = Offer.Agent, Tags = Offer.Tags, PropertyId = Offer.PropertyId, ClientUserName = Offer.ClientUserName, Comission = 100, Description = Offer.Description, Price = Offer.Price, State = OfferState.Published, Title = Offer.Title }); unitOfWork.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// 分页查询 /// </summary> /// <param name="pagecurr">当前页</param> /// <param name="pagesize">页容量</param> /// <returns></returns> public List <SellOffer> SearchBypage(int pagecurr, int pagesize) { List <SellOffer> list = new List <SellOffer>(); int startindex = (pagecurr - 1) * pagesize; int endindex = pagecurr * pagesize; DataTable dt = SqlHelper.Search(@"select * from (SELECT *, ROW_NUMBER() over(order by Id) as 'row' FROM Products_SellOffer) as A where A.row between @startindex and @endindex", new SqlParameter[] { new SqlParameter("startindex", startindex), new SqlParameter("endindex", endindex) }); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { SellOffer selloffer = new SellOffer(); selloffer.Id = (int)dt.Rows[i]["Id"]; selloffer.Title = dt.Rows[i]["Title"].ToString(); selloffer.Keywords = dt.Rows[i]["Keywords"].ToString(); selloffer.SysAttr = dt.Rows[i]["SysAttr"].ToString(); selloffer.CusAttr = dt.Rows[i]["CusAttr"].ToString(); list.Add(selloffer); } } return(list); }
public void Edit(SellOffer sellOffer) { _context.SaveChanges(); }