public ActionResult Create(Subscriber subscriber, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null && image.ContentType.StartsWith("image/")) { subscriber.ImageMimeType = image.ContentType; subscriber.ImageData = new byte[image.ContentLength]; image.InputStream.Read(subscriber.ImageData, 0, image.ContentLength); } db.Subscribers.Add(subscriber); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subscriber)); }
public ActionResult Edit(EditBillViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Guid userGuid = new Guid(User.Identity.GetUserId()); model.Bill.UserId = userGuid; Bill bill = Mapper.Map <BillViewModel, Bill>(model.Bill); bill.BackgroundColor = bill.BackgroundColor.Replace("#", ""); bill.ForeColor = bill.ForeColor.Replace("#", ""); db.Entry(bill).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }