Example #1
0
        public ActionResult Create(Client client)
        {
            if (ModelState.IsValid)
            {
                var image = WebImage.GetImageFromRequest("UploadedImage");

                if (image != null)
                    client.MainImage = Server.MapPath("/Images/Clients/").SaveImage(image);

                client.Date_Creation = DateTime.Now;

                context.Clients.Add(client);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(client);
        }
Example #2
0
        public ActionResult Edit(Client client)
        {
            if (ModelState.IsValid)
            {
                var image = WebImage.GetImageFromRequest("UploadedImage");

                if (image != null)
                    client.MainImage = Server.MapPath("/Images/Clients/").SaveImage(image);

                context.Entry(client).State = EntityState.Modified;
                context.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(client);
        }