Exemplo n.º 1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)

            {
                User a = new User();
                a.Id           = user.Id;
                a.Name         = user.Name;
                a.Login        = user.Login;
                a.Password     = Encrypt(user.Password);
                a.Position     = user.Position;
                a.DepartmentId = user.DepartmentId;
                a.RoleId       = user.RoleId;
                db.Users.Add(a);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            SelectList departments = new SelectList(db.Departments, "Id", "Name");

            ViewBag.Departments = departments;
            SelectList roles = new SelectList(db.Roles, "Id", "Name");

            ViewBag.Roles = roles;

            return(View(user));
        }
Exemplo n.º 2
0
        public int SaveRequest(Request requst)
        {
            var savedRequest = _helpdeskContext.Request.Add(requst);

            _helpdeskContext.SaveChanges();
            return(savedRequest.Entity.Id);
        }
Exemplo n.º 3
0
        public ActionResult Create(Request request, HttpPostedFileBase error)
        {
            User user = db.Users.FirstOrDefault(x => x.Login == HttpContext.User.Identity.Name);

            if (user == null)
            {
                return(RedirectToAction("LogOff", "Account"));
            }
            if (ModelState.IsValid)
            {
                request.Status = (int)RequestStatus.Open;
                var lifeCycle = new Lifecycle()
                {
                    Opened = DateTime.Now
                };
                db.Lifecycles.Add(lifeCycle);
                request.UserId = user.Id;
                if (error != null)
                {
                    string ext  = error.FileName.Substring(error.FileName.LastIndexOf('.'));
                    string path = DateTime.Now.ToString("dd/MM/yyyy H:mm:ss").Replace(":", "_").Replace("/", ".") + ext;
                    error.SaveAs(Server.MapPath("~/Files/" + path));
                    request.File = path;
                }
                db.Requests.Add(request);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(request));
        }
        // =========================================== INSERT =============================================
        public void InsertSubCategory()
        {
            Console.Clear();
            System.Console.Write("SubCategory Name      : ");
            string catname = System.Console.ReadLine();

            System.Console.Write("Category ID           : ");
            int catid = Convert.ToInt32(System.Console.ReadLine());

            SubCategoryCls call = new SubCategoryCls();

            {
                call.SubCategory_Name = catname;
                //call.CategoryID = catid;
            };
            try
            {
                hld_context.SubCategory_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
        // =========================================== INSERT =============================================
        public void InsertDueDate()
        {
            Console.Clear();
            System.Console.Write("Tipe               : ");
            string Tipe = System.Console.ReadLine();

            System.Console.Write("Interval Type      : ");
            int interval = Convert.ToInt32(System.Console.ReadLine());

            DueDateCls call = new DueDateCls();

            {
                call.Type     = Tipe;
                call.Interval = interval;
            };
            try
            {
                hld_context.DueDate_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
Exemplo n.º 6
0
        public Task Post(HelpDeskTickets newHelpDeskTickets)
        {
            // Add a new Help Desk Ticket
            helpdeskContext.HelpDeskTickets.Add(newHelpDeskTickets);
            helpdeskContext.SaveChanges();

            return(Task.FromResult(newHelpDeskTickets));
        }
        // =========================================== INSERT =============================================
        public void InsertTicket()
        {
            Console.Clear();
            System.Console.Write("Username      : "******"Password      : "******"First Name    : ");
            string First_Name = System.Console.ReadLine();

            System.Console.Write("Last Name     : ");
            string Last_Name = System.Console.ReadLine();

            System.Console.Write("Address       : ");
            string Address = System.Console.ReadLine();

            System.Console.Write("City          : ");
            string City = System.Console.ReadLine();

            System.Console.Write("Phone         : ");
            string phone = System.Console.ReadLine();

            System.Console.Write("Email         : ");
            string email = System.Console.ReadLine();

            System.Console.Write("Department ID : ");
            int DepartmentID = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Role ID       : ");
            int RoleID = Convert.ToInt32(System.Console.ReadLine());

            UserCls call = new UserCls();

            {
                call.Username     = Username;
                call.Password     = Password;
                call.First_Name   = First_Name;
                call.Last_Name    = Last_Name;
                call.Address      = Address;
                call.City         = City;
                call.Phone        = phone;
                call.Email        = email;
                call.DepartmentID = DepartmentID;
                call.RoleID       = RoleID;
            };
            try
            {
                hld_context.User_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
Exemplo n.º 8
0
        // =========================================== INSERT =============================================
        public void InsertTicket()
        {
            Console.Clear();
            System.Console.Write("Description       : ");
            string description = System.Console.ReadLine();

            System.Console.Write("Date Create       : ");
            DateTime dtmcrt = Convert.ToDateTime(System.Console.ReadLine());

            System.Console.Write("Due Date          : ");
            DateTime duedt = Convert.ToDateTime(System.Console.ReadLine());

            System.Console.Write("L1                : ");
            string l1 = System.Console.ReadLine();

            System.Console.Write("Technician        : ");
            string technc = System.Console.ReadLine();

            System.Console.Write("Type ID           : ");
            int tid = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("User ID           : ");
            int uid = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Category ID       : ");
            int cid = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("SubCategory ID    : ");
            int scid = Convert.ToInt32(System.Console.ReadLine());


            TicketCls call = new TicketCls();

            {
                call.Description   = description;
                call.Dtm_Crt       = dtmcrt;
                call.L1            = l1;
                call.DueDate       = duedt;
                call.Technician    = technc;
                call.TypeID        = tid;
                call.UserID        = uid;
                call.CategoryID    = cid;
                call.SubCategoryID = scid;
            };
            try
            {
                hld_context.Ticket_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
Exemplo n.º 9
0
 public ActionResult Create(User user)
 {
     if (ModelState.IsValid)
     {
         db.Users.Add(user);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Departments = new SelectList(db.Departments, "Id", "Name");
     ViewBag.Roles       = new SelectList(db.Roles, "Id", "Name");
     return(View(user));
 }
        public ActionResult Create(Request request, HttpPostedFileBase error)
        {
            // получаем текущего пользователя
            User user = db.Users.Where(m => m.Login == HttpContext.User.Identity.Name).FirstOrDefault();

            if (user == null)
            {
                return(RedirectToAction("LogOff", "Account"));
            }
            if (ModelState.IsValid)
            {
                // указываем статус Открыта у заявки
                request.Status = (int)RequestStatus.Open;
                //получаем время октрытия
                DateTime current = DateTime.Now;

                //Создаем запись о жизненом цикле заявки
                Lifecycle newLifecycle = new Lifecycle()
                {
                    Opened = current
                };
                request.Lifecycle = newLifecycle;

                //Добавляем жизенный цикл заявки
                db.Lifecycles.Add(newLifecycle);

                // указываем пользователя заявки
                request.UserId = user.Id;

                // если получен файл
                if (error != null)
                {
                    // Получаем расширение
                    string ext = error.FileName.Substring(error.FileName.LastIndexOf('.'));
                    // сохраняем файл по определенному пути на сервере
                    string path = current.ToString("dd.mm.yyyy hh:mm:ss").Replace(":", "_").Replace("/", ".") + ext;
                    error.SaveAs(Server.MapPath("~/Files/" + path));
                    request.File = path;
                }
                //Добавляем заявку
                db.Requests.Add(request);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(request));
        }
Exemplo n.º 11
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            SelectList departments = new SelectList(db.Departments, "Id", "Name");

            ViewBag.Departments = departments;
            SelectList roles = new SelectList(db.Roles, "Id", "Name");

            ViewBag.Roles = roles;

            return(View(user));
        }
        // =========================================== INSERT =============================================
        public void InsertCategory()
        {
            Console.Clear();
            System.Console.Write("Category Name      : ");
            string catname = System.Console.ReadLine();

            CategoryCls call = new CategoryCls();

            {
                call.Category_Name = catname;
            };
            try
            {
                hld_context.Category_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
        // =========================================== INSERT =============================================
        public void InsertRole()
        {
            Console.Clear();
            System.Console.Write("Nama Role : ");
            string Nama_Role = System.Console.ReadLine();

            RoleCls call = new RoleCls();

            {
                call.Role = Nama_Role;
            };
            try
            {
                hld_context.Role_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
Exemplo n.º 14
0
        // =========================================== INSERT =============================================
        public void InsertDepartment()
        {
            Console.Clear();
            System.Console.Write("Nama Department : ");
            string Nama_Department = System.Console.ReadLine();

            DepartmentCls call = new DepartmentCls();

            {
                call.Department_Name = Nama_Department;
            };
            try
            {
                hld_context.Department_s.Add(call);
                var result = hld_context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }
Exemplo n.º 15
0
 public ActionResult Departments(Department dept)
 {
     if (ModelState.IsValid)
     {
         _db.Departments.Add(dept);
         _db.SaveChanges();
     }
     ViewBag.Departments = _db.Departments;
     return(View(dept));
 }
Exemplo n.º 16
0
 public ActionResult Department(Department depo)
 {
     if (ModelState.IsValid)
     {
         db.Departments.Add(depo);
         db.SaveChanges();
     }
     ViewBag.Departments = db.Departments;
     return(View(depo));
 }
Exemplo n.º 17
0
        public ActionResult Create(Request request, HttpPostedFileBase error)
        {
            ViewBag.Cabs       = new SelectList(db.Activs, "Id", "CabNumber");
            ViewBag.Categories = new SelectList(db.Categories, "Id", "Name");
            // получаем текущего пользователя
            User user = db.Users.Where(m => m.Login == HttpContext.User.Identity.Name).FirstOrDefault();

            if (user == null)
            {
                return(RedirectToAction("LogOff", "Account"));
            }
            if (ModelState.IsValid)
            {
                // указываем статус Открыта у заявки
                request.Status = (int)RequestStatus.Open;
                //получаем время открытия
                DateTime current = DateTime.Now;

                //Создаем запись о жизненном цикле заявки
                Lifecycle newLifecycle = new Lifecycle()
                {
                    Opened = current
                };
                request.Lifecycle = newLifecycle;

                //Добавляем жизненный цикл заявки
                db.Lifecycles.Add(newLifecycle);

                // указываем пользователя заявки
                request.UserId = user.Id;

                // если получен файл
                if (error != null)
                {
                    // Получаем расширение
                    string ext = error.FileName.Substring(error.FileName.LastIndexOf('.'));
                    // сохраняем файл по определенному пути на сервере
                    string path = current.ToString("dd/MM/yyyy H:mm:ss").Replace(":", "_").Replace("/", ".") + ext;
                    error.SaveAs(Server.MapPath("~/Files/" + path));
                    request.File = path;
                }
                //Добавляем заявку
                db.Requests.Add(request);
                db.SaveChanges();

                // отправляем mail уведомление про созданя заявки ******************************
                //получаем номер кабинета и название отдела
                var DepartActiv = db.Activs.Where(m => m.Id == request.ActivId)
                                  .Join(db.Departments, a => a.DepartmentId, d => d.Id,
                                        (a, d) => new { a.CabNumber, d.Name }).FirstOrDefault();
                // название категории проблемы
                Category categori = db.Categories.Where(m => m.Id == request.CategoryId).FirstOrDefault();

                var mailController = new EmailProvider();
                var mailtemplate   = new EmailTemplate()
                {
                    UserName    = user.Name, UserLastname = user.LastName, UserEmail = user.Email, UserPosition = user.Position, UserDepartment = DepartActiv.Name, UserPhoneNumber = user.PhoneNumber,
                    RequestName = request.Name, RequestActiv = DepartActiv.CabNumber, RequestCategory = categori.Name, RequestComment = request.Comment, RequestDescription = request.Description, RequestPriority = request.Priority
                };
                var email = mailController.Subscription(mailtemplate, "*****@*****.**");
                email.Deliver();
                // конец  отправляем mail уведомление про созданя заявки ***********************
                return(RedirectToAction("Index"));
            }
            return(View(request));
        }