public JsonResult Update(LotModel lotModel) { var lot = MyLotsRepository.GetById(HttpContext.User.Identity.Name, lotModel.Id); lot.Name = lotModel.Name; lot.Description = lotModel.Description; lot.Price = lotModel.Price; MyLotsRepository.Update(lot); return JsonSuccess(new { Lots = new[] { LotModel.FromLot(lot) } }); }
public static LotModel FromLot(Lot lot) { var lotModel = new LotModel { Id = lot.Id, Name = lot.Name, Description = lot.Description, DateTime = lot.DateTime, Hidden = lot.Hidden, Price = lot.Price, User = lot.User.Name }; return lotModel; }
public JsonResult Add(LotModel lotModel) { var lot = new Lot { Name = lotModel.Name, Description = lotModel.Description, Price = lotModel.Price }; MyLotsRepository.Save(HttpContext.User.Identity.Name, lot); return JsonSuccess(new { Lots = new [] { LotModel.FromLot(lot) } }); }
public JsonResult Remove(LotModel lotModel) { var lot = MyLotsRepository.GetById(HttpContext.User.Identity.Name, lotModel.Id); MyLotsRepository.Remove(lot); return JsonSuccess(); }