public ActionResult Create(SellingItemInputModel model) { if (model != null && ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map <SellingItem>(model); var imageUploader = new ImageUplouder(); var images = new HashSet <Image>(); string folderPath = Server.MapPath(WebConstants.ImagesMainPathMap + currentUserId); if (model.Files != null && model.Files.Count() > 0) { foreach (var file in model.Files) { if (file != null && (file.ContentType == WebConstants.ContentTypeJpg || file.ContentType == WebConstants.ContentTypePng) && file.ContentLength < WebConstants.MaxImageFileSize) { images.Add(imageUploader.UploadImage(file, folderPath, currentUserId)); } } } newArticle.SellerId = currentUserId; newArticle.Images = images; var result = this.sellingItems.Create(newArticle); return(this.RedirectToAction("Details", "Shop", new { area = "", id = result })); } return(this.View(model)); }
public ActionResult Create(SellingItemInputModel model) { if (model != null && ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map<SellingItem>(model); var imageUploader = new ImageUplouder(); var images = new HashSet<Image>(); string folderPath = Server.MapPath(WebConstants.ImagesMainPathMap + currentUserId); if (model.Files != null && model.Files.Count() > 0) { foreach (var file in model.Files) { if (file != null && (file.ContentType == WebConstants.ContentTypeJpg || file.ContentType == WebConstants.ContentTypePng) && file.ContentLength < WebConstants.MaxImageFileSize) { images.Add(imageUploader.UploadImage(file, folderPath, currentUserId)); } } } newArticle.SellerId = currentUserId; newArticle.Images = images; var result = this.sellingItems.Create(newArticle); return this.RedirectToAction("Details", "Shop", new { area = "", id = result }); } return this.View(model); }
public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, SellingItemInputModel model) { if (ModelState.IsValid && model != null) { this.items.Destroy(model.Id, null); } return(this.GridOperationObject(model, request)); }
public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, SellingItemInputModel model) { if (ModelState.IsValid && model != null) { this.items.Destroy(model.Id, null); } return this.GridOperationObject(model, request); }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, SellingItemInputModel model) { if (model != null && this.ModelState.IsValid) { var updated = this.Mapper.Map <SellingItem>(model); updated.Images = null; this.items.Update(model.Id, updated); return(this.GridOperationObject(model, request)); } return(null); }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, SellingItemInputModel model) { if (model != null && this.ModelState.IsValid) { var updated = this.Mapper.Map<SellingItem>(model); updated.Images = null; this.items.Update(model.Id, updated); return this.GridOperationObject(model, request); } return null; }
public ActionResult Create([DataSourceRequest] DataSourceRequest request, SellingItemInputModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map <SellingItem>(model); newArticle.SellerId = currentUserId; var modelId = this.items.Create(newArticle); model.Id = modelId; model.SellerId = currentUserId; model.SellerName = this.UserProfile.UserName; return(this.GridOperationObject(model, request)); } return(null); }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, SellingItemInputModel model) { if (model != null && this.ModelState.IsValid) { var currentUserId = this.UserProfile.Id; var newArticle = this.Mapper.Map<SellingItem>(model); newArticle.SellerId = currentUserId; var modelId = this.items.Create(newArticle); model.Id = modelId; model.SellerId = currentUserId; model.SellerName = this.UserProfile.UserName; return this.GridOperationObject(model, request); } return null; }