Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "id,location,logo,aboutext,fblink,instalink,twitlink,dentalemergancyphto,dentalemergancytext,mapsource")] helpdesk helpdesk, HttpPostedFileBase dentalemergancyphto, HttpPostedFileBase logo)
 {
     if (ModelState.IsValid)
     {
         if (dentalemergancyphto == null && logo == null)
         {
             db.Entry(helpdesk).Property(h => h.dentalemergancyphto).IsModified = false;
             db.Entry(helpdesk).Property(h => h.logo).IsModified = false;
         }
         else
         {
             if (dentalemergancyphto != null)
             {
                 string filname = DateTime.Now.ToString("yyyyMMddHHmmss") + dentalemergancyphto.FileName;
                 var    myfile  = System.IO.Path.Combine(Server.MapPath("~/Uploads"), filname);
                 dentalemergancyphto.SaveAs(myfile);
                 helpdesk.dentalemergancyphto = filname;
             }
             if (logo != null)
             {
                 string finame = DateTime.Now.ToString("yyyyMMddHHmmss") + logo.FileName;
                 var    mfile  = System.IO.Path.Combine(Server.MapPath("~/Uploads"), finame);
                 logo.SaveAs(mfile);
                 helpdesk.logo = finame;
             }
         }
         db.Entry(helpdesk).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(helpdesk));
 }
Exemplo n.º 2
0
        public void UpdateTicket(TicketProfileView ticket)
        {
            using (mwdEntities db = new mwdEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        helpdesk HD = db.helpdesks.Find(ticket.ID);
                        HD.UserID               = ticket.UserID;
                        HD.SeverityID           = ticket.SeverityID;
                        HD.StatusID             = ticket.StatusID;
                        HD.DepartmentID         = ticket.DepartmentID;
                        HD.Comments             = ticket.Comments;
                        HD.RowModifiedSYSUserID = ticket.SYSUserID;
                        HD.RowModifiedDateTime  = DateTime.Now;

                        db.SaveChanges();
                        dbContextTransaction.Commit();
                    }
                    catch
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            helpdesk helpdesk = db.helpdesks.Find(id);

            db.helpdesks.Remove(helpdesk);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        // GET: Maneger/helpdesks/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            helpdesk helpdesk = db.helpdesks.Find(id);

            if (helpdesk == null)
            {
                return(HttpNotFound());
            }
            return(View(helpdesk));
        }
Exemplo n.º 5
0
        public void AddTicket(TicketCreateView ticket)
        {
            using (mwdEntities db = new mwdEntities())
            {
                helpdesk HD = new helpdesk();
                HD.UserID               = ticket.UserID;
                HD.StatusID             = ticket.StatusID;
                HD.SeverityID           = ticket.SeverityID;
                HD.DepartmentID         = ticket.DepartmentID;
                HD.Comments             = ticket.Comments;
                HD.RowCreatedSYSUserID  = ticket.UserID > 0 ? ticket.UserID : 1;
                HD.RowModifiedSYSUserID = ticket.UserID > 0 ? ticket.UserID : 1;
                HD.RowCreatedDateTime   = DateTime.Now;
                HD.RowModifiedDateTime  = DateTime.Now;

                db.helpdesks.Add(HD);
                db.SaveChanges();
            }
        }
Exemplo n.º 6
0
 public ActionResult Create([Bind(Include = "id,location,aboutext,fblink,instalink,twitlink,dentalemergancytext,mapsource")] helpdesk helpdesk, HttpPostedFileBase dentalemergancyphto, HttpPostedFileBase logo)
 {
     if (dentalemergancyphto.ContentType != "image/jpeg" && dentalemergancyphto.ContentType != "image/png" && dentalemergancyphto.ContentType != "image/gif")
     {
         return(Content("Fayl qebul olunmur"));
     }
     if (ModelState.IsValid)
     {
         string filname = DateTime.Now.ToString("yyyyMMddHHmmss") + dentalemergancyphto.FileName;
         var    myfile  = System.IO.Path.Combine(Server.MapPath("~/Uploads"), filname);
         dentalemergancyphto.SaveAs(myfile);
         helpdesk.dentalemergancyphto = filname;
         string finame = DateTime.Now.ToString("yyyyMMddHHmmss") + dentalemergancyphto.FileName;
         var    mfile  = System.IO.Path.Combine(Server.MapPath("~/Uploads"), finame);
         logo.SaveAs(mfile);
         helpdesk.logo = finame;
         db.helpdesks.Add(helpdesk);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(helpdesk));
 }