Exemplo n.º 1
0
        public ActionResult Create()
        {
            MembershipUser currentuser_ = new UserRepository().GetUser(User.Identity.Name);
            int user_wherecondition = int.Parse((currentuser_.ProviderUserKey).ToString());

            ViewBag.RequestTypeID = new SelectList(db.RequestTypes, "RequestTypeID", "Description");
            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Description");
            ViewBag.InventoryID = new SelectList(db.Inventories, "InventoryID", "Description");
            ViewBag.WorkshopID = new SelectList(db.Workshops, "WorkshopID", "Description");
            ViewBag.RequestStateID = new SelectList(db.RequestStates, "RequestStateID", "Description",1);
            ViewBag.UserReqID = new SelectList(db.Users.Where(x => x.UserId == user_wherecondition), "UserId", "UserName", currentuser_.ProviderUserKey);
            ViewBag.UserID = new SelectList(db.Users, "UserId", "UserName",currentuser_.ProviderUserKey);
            ViewBag.ValidationStateID = new SelectList(db.ValidationStates, "ValidationStateID", "Description");
            ViewBag.timestamp = DateTime.Now;
            return View();
        }
Exemplo n.º 2
0
        public ActionResult Create(RequestIssue requestıssue)
        {
            if (ModelState.IsValid)
            {
                requestıssue.TimeStamp = DateTime.Now;
                requestıssue.ValidationStateID = 2;
                db.RequestIssues.Add(requestıssue);
                db.SaveChanges();
                return RedirectToAction("Details/" + requestıssue.RequestIssueID.ToString());
            }

            MembershipUser currentuser_ = new UserRepository().GetUser(User.Identity.Name);
            int user_wherecondition = int.Parse((currentuser_.ProviderUserKey).ToString());

            ViewBag.RequestTypeID = new SelectList(db.RequestTypes, "RequestTypeID", "Description", requestıssue.RequestTypeID);
            ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "Description", requestıssue.LocationID);
            ViewBag.InventoryID = new SelectList(db.Inventories, "InventoryID", "Description", requestıssue.InventoryID);
            ViewBag.WorkshopID = new SelectList(db.Workshops, "WorkshopID", "Description", requestıssue.WorkshopID);
            ViewBag.RequestStateID = new SelectList(db.RequestStates, "RequestStateID", "Description", requestıssue.RequestStateID);
            ViewBag.UserReqID = new SelectList(db.Users.Where(x => x.UserId == user_wherecondition), "UserId", "UserName", requestıssue.UserReqID);
            ViewBag.UserID = new SelectList(db.Users, "UserId", "UserName", requestıssue.UserID);
            ViewBag.ValidationStateID = new SelectList(db.ValidationStates, "ValidationStateID", "Description", requestıssue.ValidationStateID);
            return View(requestıssue);
        }
Exemplo n.º 3
0
        public ActionResult Create(Project project, FormCollection formcollection)
        {
            MembershipUser currentuser_ = new UserRepository().GetUser(User.Identity.Name);
            int user_wherecondition = int.Parse((currentuser_.ProviderUserKey).ToString());

            if (ModelState.IsValid)
            {
                project.TimeStamp = DateTime.Now;
                project.cUserID = user_wherecondition;
                project.RequestStateID = 4;
                db.Projects.Add(project);
                db.SaveChanges();

                if (formcollection["LocationID"] != null)
                {
                    foreach (var location_ in formcollection["LocationID"].Split(',').ToList())
                    {
                        try
                        {
                            int location_index = int.Parse(location_.ToString());
                            var x_location = db.Locations.Find(location_index);
                            x_location.Projects.Add(project);
                        }
                        catch
                        { }
                        db.SaveChanges();
                    }
                }

                if (formcollection["CorporateAccountID"] != null)
                {
                    foreach (var corp_ in formcollection["CorporateAccountID"].Split(',').ToList())
                    {
                        try
                        {
                            int corp_index = int.Parse(corp_.ToString());
                            var x_corp = db.CorporateAccounts.Find(corp_index);
                            x_corp.Projects.Add(project);
                        }
                        catch
                        { }

                        db.SaveChanges();
                    }
                }

                if (formcollection["PersonnelID"] != null)
                {
                    foreach (var pers_ in formcollection["PersonnelID"].Split(',').ToList())
                    {
                        try
                        {
                            int pers_index = int.Parse(pers_.ToString());
                            var x_pers = db.Personnels.Find(pers_index);
                            x_pers.Projects.Add(project);
                        }
                        catch
                        { }
                        db.SaveChanges();
                    }
                }

                return RedirectToAction("Index");
            }

            ViewBag.RequestStateID = new SelectList(db.RequestStates, "RequestStateID", "Description", project.RequestStateID);
            ViewBag.UserID = new SelectList(db.Users, "UserId", "FullName", project.UserID);
            ViewBag.cUserID = new SelectList(db.Users, "UserId", "UserName", project.cUserID);

            if (formcollection["LocationID"] != null)
            {
                ViewBag.LocationID = new MultiSelectList(db.Locations, "LocationID", "CapitalizedDescription", formcollection["LocationID"].Split(',').ToList());
            }
            else
            {
                ViewBag.LocationID = new MultiSelectList(db.Locations, "LocationID", "Description");
            }

            if (formcollection["CorporateAccountID"] != null)
            {
                ViewBag.CorporateAccountID = new MultiSelectList(db.CorporateAccounts, "CorporateAccountID", "Title", formcollection["CorporateAccountID"].Split(',').ToList());
            }
            else
            {
                ViewBag.CorporateAccountID = new MultiSelectList(db.CorporateAccounts, "CorporateAccountID", "Title");
            }

            if (formcollection["PersonnelID"] != null)
            {
                ViewBag.PersonnelID = new MultiSelectList(db.Personnels, "PersonnelID", "FullName", formcollection["PersonnelID"].Split(',').ToList());
            }
            else
            {
                ViewBag.PersonnelID = new MultiSelectList(db.Personnels, "PersonnelID", "FullName");
            }
            return View(project);
        }
Exemplo n.º 4
0
        public ActionResult Validate(int id)
        {
            RequestIssue requestissue = db.RequestIssues.Find(id);

            if ((requestissue.UserReq.UserName == User.Identity.Name) && (requestissue.ValidationStateID != 1))
            {
                requestissue.ValidationStateID = 1;
                db.Entry(requestissue).State = EntityState.Modified;
                db.SaveChanges();

                if (requestissue.SendEmail == true)
                {
                    MembershipUser currentuser_ = new UserRepository().GetUser(User.Identity.Name);
                    SendEmail(new MailAddress("*****@*****.**"), new MailAddress(currentuser_.Email), "[Klimasan HelpDesk] İş isteğiniz hakkında.", "İsteğiniz doğrulanarak kayıt altına alınmıştır.Tarih: "+DateTime.Now.ToString()+" - İş No: #" + (requestissue.RequestIssueID).ToString() + ". İyi çalışmalar dileriz.");
                }
                return RedirectToAction("Index");
            }
            else
            {
                ViewBag.UserError = "Bu İş için doğrulama için yetkisi yok ya da zaten doğrulanmış.";
            }
            return RedirectToAction("Index");
        }
Exemplo n.º 5
0
        public ActionResult Edit(string username_,string err)
        {
            int _userid = db.Users.Where(i => i.UserName == username_).SingleOrDefault().UserId;
            User user_ = db.Users.Include(p=>p.Roles).Include(p=>p.Workshops).Include(p=>p.WorkshopPermissions).Include(p => p.UserGroups).Include(p => p.CustomPermissions).Where(i => i.UserId == _userid).SingleOrDefault();

            IList<WorkshopPermission> MyWorkshopPermissions = new List<WorkshopPermission>();

            foreach (WorkshopPermission wrp_item in user_.WorkshopPermissions.ToList())
            {
                MyWorkshopPermissions.Add(wrp_item);
            }
            ViewBag.TheWorkshopPermissionsCount = MyWorkshopPermissions.Count;
            ViewBag.TheWorkshopPermissions = MyWorkshopPermissions;
            ViewBag.ErrorMessage = err;
            ViewBag.WorkshopID = new SelectList(db.Workshops, "WorkshopID", "Description");

            //herkes altındakilerin yetkilerini duzenleyebilir.?
            MembershipUser currentuser_ = new UserRepository().GetUser(User.Identity.Name);
            int user_wherecondition = int.Parse((currentuser_.ProviderUserKey).ToString());
            User Currentuser_ = db.Users.AsNoTracking().Include(p => p.Roles).Include(p => p.WorkshopPermissions).Where(i => i.UserId == user_wherecondition).SingleOrDefault();

            try
            {
                int usr_role_min = Currentuser_.Roles.Min(p => p.RoleID);
                var usr_roles_toadminister = db.Roles.AsNoTracking().Where(i=> i.RoleID>usr_role_min).ToList();

                List<int> userids = new List<int>();
                foreach (var role_ in usr_roles_toadminister)
                {
                    foreach (int ui in role_.Users.Select(i=>i.UserId).ToList())
                    {
                        userids.Add(ui);
                    }
                }

                ViewBag.UserID = new SelectList(db.Users.Where(s=>userids.Contains(s.UserId)) , "UserId", "FullNameWithUsername");
            }
            catch
            {

                ViewBag.UserID = new SelectList(db.Users.Where(u=> u.UserId<0), "UserId", "FullNameWithUsername");
            }

            ViewBag.RoleId = new MultiSelectList(db.Roles, "RoleID", "Description", user_.Roles.Select(p => p.RoleID).ToList());
            ViewBag.WorkshopMultiSelectID = new MultiSelectList(db.Workshops, "WorkshopID", "Description",user_.Workshops.Select(p=>p.WorkshopID).ToList());
            ViewBag.ModuleID = new MultiSelectList(db.Modules, "ModuleID", "Description", user_.Modules.Select(p => p.ModuleID).ToList());
            ViewBag.UserGroupID = new MultiSelectList(db.UserGroups, "UserGroupID", "Name",user_.UserGroups.Select(p=>p.UserGroupID).ToList());
            ViewBag.CustomPermissionID = new MultiSelectList(db.CustomPermissions, "CustomPermissionID", "Description",user_.CustomPermissions.Select(p=>p.CustomPermissionID).ToList());

            return View(user_);
        }