Esempio n. 1
0
        public ActionResult Edit(VM.Event_Type evm)
        {
            if (ModelState.IsValid)
            {
                if (evm.EventTypeImage != null)
                {
                    string newfilename  = Guid.NewGuid().ToString() + Path.GetExtension(evm.EventTypeImage.FileName);
                    string newpath      = Path.Combine("Images", "EvType", newfilename);
                    string filetoFolder = Path.Combine(Server.MapPath("~/" + newpath));
                    evm.EventTypeImage.SaveAs(filetoFolder);

                    string   FileName = evm.EventTypeImagePath;
                    string   img      = Path.Combine(Server.MapPath("~/" + FileName));
                    FileInfo file     = new FileInfo(img);
                    if (file.Exists)
                    {
                        file.Delete();
                    }

                    Event_Type event_Type = new Event_Type {
                        EventTypeId = evm.EventTypeId, EventType = evm.EventType, EventTypeImage = newpath
                    };

                    db.Entry(event_Type).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    Event_Type event_Type = new Event_Type {
                        EventTypeId = evm.EventTypeId, EventType = evm.EventType, EventTypeImage = evm.EventTypeImagePath
                    };

                    db.Entry(event_Type).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(evm));
        }
 public ActionResult Edit([Bind(Include = "RoleId,RoleName")] Role role)
 {
     if (ModelState.IsValid)
     {
         db.Entry(role).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(role));
 }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "Id,Name,FatherName,Address,Mobile,Email")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
 public ActionResult Edit([Bind(Include = "tblUserId,UserName,Password,RoleId")] tblUser tblUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoleId = new SelectList(db.Roles, "RoleId", "RoleName", tblUser.RoleId);
     return(View(tblUser));
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "BookedEventId,EventTypeId,CustomerId,StartTime,EndTime,EntryDate")] ScheduleEvent scheduleEvent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(scheduleEvent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerId  = new SelectList(db.Customers, "Id", "Name", scheduleEvent.CustomerId);
     ViewBag.EventTypeId = new SelectList(db.Event_Types, "EventTypeId", "EventType", scheduleEvent.EventTypeId);
     return(View(scheduleEvent));
 }