예제 #1
0
        public ActionResult AddNewClient(ClientModel np, string mainContact)
        {
            ViewBag.Url = "/Images/" + User.Identity.Name + "_profile.jpg";
            DAL d = new DAL();

            ViewBag.RoleId = d.getRoleID(CurrentUser.Role);
            if (ModelState.IsValid)
            {
                ProjectManager pm = new ProjectManager();
                var            c  = pm.FetchUsers();
                ViewBag.Users = c;
                if (!pm.DoesNameExist(np.Name))
                {
                    np.DateAdded = System.DateTime.Now;
                    string s = CurrentUser.Sid;
                    pm.AddClient(np, mainContact, s);

                    return(RedirectToAction("BrowseClients"));
                }
                else
                {
                    ModelState.AddModelError("", "Client name already exists.");
                    return(View(np));
                }
            }

            return(View());
        }