public ActionResult Create(ProductCategory productCategory) { if (!ModelState.IsValid) { return(View(productCategory)); } else { context.Insert(productCategory); context.Commit(); return(RedirectToAction("Index")); } }
private Basket CreateNewBasket(HttpContextBase httpContext) { Basket basket = new Basket(); basketContext.Insert(basket); HttpCookie cookie = new HttpCookie(BasketSession); cookie.Value = basket.Id; cookie.Expires = DateTime.Now.AddDays(1); httpContext.Response.Cookies.Add(cookie); return(basket); }
public ActionResult Create(Product product, HttpPostedFileBase file) { if (!ModelState.IsValid) { return(View(product)); } else { if (file != null) { product.Image = product.Id + Path.GetExtension(file.FileName); file.SaveAs(Server.MapPath("//Content//ProductImages//") + product.Image); } context.Insert(product); context.Commit(); return(RedirectToAction("Index")); } }
public async Task <BaseResponse> Insert(Movie entity) { if (string.IsNullOrWhiteSpace(entity.MovieName)) { return(new BaseResponse { ErrorCode = 1, Messege = String.Format(_errorHandler.GetMessage(ErrorMessagesEnum.ModelValidation), "Movie Name is Null") }); } var movie = await _respository.Insert(entity); return(new BaseResponse { ErrorCode = 0, Messege = _errorHandler.GetMessage(ErrorMessagesEnum.AddSuccess), Data = movie }); }