Beispiel #1
0
        public ActionResult Edit(Function model)
        {
            if (ModelState.IsValid)
            {
                model.StartDate     = DateTime.ParseExact(model.StartDateTemp, "dd/MM/yyyy", null);
                model.ExpectEndDate = DateTime.ParseExact(model.ExpectEndDateTemp, "dd/MM/yyyy", null);
                var item = uow.FunctionRepo.GetByID(model.ID);
                if (item != null)
                {
                    item.FuncName      = model.FuncName;
                    item.Description   = model.Description;
                    item.DevID         = model.DevID;
                    item.StartDate     = model.StartDate;
                    item.ExpectEndDate = model.ExpectEndDate;
                    item.Status        = model.Status;
                    item.ProjectID     = model.ProjectID;

                    uow.FunctionRepo.Update(item);
                    uow.Save();
                    var routeVals = TypeHelper.ObjectToDictionary(new { projectId = model.ProjectID });
                    routeVals["controller"] = "Function";
                    routeVals["action"]     = "Index";
                    return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext)));
                }
                ModelState.AddModelError("", "Database connection error!");
            }
            return(View(model));
        }
Beispiel #2
0
        public new ActionResult RedirectToAction(string actionName, string controllerName, object routeValues)
        {
            var routeVals = TypeHelper.ObjectToDictionary(routeValues);

            routeVals["controller"] = controllerName;
            routeVals["action"]     = actionName;
            return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext)));
        }
Beispiel #3
0
        public ActionResult Create(Function model, int projectId = 0)
        {
            ViewBag.Users  = new SelectList(uow.ProjectRepo.GetEmployees(projectId), "UserID", "DisplayName", model.DevID);
            ViewBag.Status = new SelectList(uow.ProjectStatusRepo.GetAll(), "Code", "Name", model.Status);
            var project = uow.ProjectRepo.GetByID(projectId);

            ViewBag.Project = project;
            if (Request.HttpMethod == "GET")
            {
                model.StartDate = model.ExpectEndDate = DateTime.Now;
                ModelState.Clear();
            }
            else
            {
                model.StartDate     = DateTime.ParseExact(model.StartDateTemp, "dd/MM/yyyy", null);
                model.ExpectEndDate = DateTime.ParseExact(model.ExpectEndDateTemp, "dd/MM/yyyy", null);
                if (ModelState.IsValid)
                {
                    if (uow.FunctionRepo.GetByProject(projectId).Any(s => s.Function.FuncName == model.FuncName))
                    {
                        ModelState.AddModelError("", "Function is existed");
                        return(View(model));
                    }
                    else
                    {
                        if (DateTime.Compare(model.StartDate, project.ExpectEndDate) > 0 && DateTime.Compare(model.ExpectEndDate, project.ExpectEndDate) > 0)
                        {
                            ModelState.AddModelError("", "Ngày bắt đầu và ngày kết thúc của tính năng không hợp lệ!");
                        }
                        else if ((DateTime.Compare(model.ExpectEndDate, project.ExpectEndDate) > 0 && DateTime.Compare(model.StartDate, project.ExpectEndDate) < 0) || (DateTime.Compare(model.ExpectEndDate, model.StartDate) < 0))
                        {
                            ModelState.AddModelError("ExpectEndDate", "Ngày kết thúc của tính năng không hợp lệ!");
                        }
                        else if (DateTime.Compare(model.ExpectEndDate, project.ExpectEndDate) < 0 && DateTime.Compare(model.StartDate, project.ExpectEndDate) > 0)
                        {
                            ModelState.AddModelError("StartDate", "Ngày bắt đầu của tính năng không hợp lệ!");
                        }
                        else
                        {
                            uow.FunctionRepo.Insert(model);
                            uow.Save();
                            uow.Close();
                            var routeVals = TypeHelper.ObjectToDictionary(new { });
                            routeVals["controller"] = "Project";
                            routeVals["action"]     = "Detail";
                            var url = ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext) + "?id=" + model.ProjectID;
                            return(Redirect(url));
                        }
                    }
                }
            }
            return(View(model));
        }
Beispiel #4
0
        private string GenerateUrl(string actionName, string controllerName, RouteValueDictionary routeValues, Boolean isAsync)
        {
            routeValues["controller"] = controllerName;
            routeValues["action"]     = actionName;

            if (isAsync)
            {
                routeValues["async"] = true;
            }

            return(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext));
        }
        public ActionResult RedirectToAction(string action, string controller, IDictionary <string, string> routeValues)
        {
            RouteValueDictionary newRouteValues = new RouteValueDictionary();

            newRouteValues["controller"] = controller;
            newRouteValues["action"]     = action;
            foreach (var p in routeValues)
            {
                newRouteValues[p.Key] = p.Value;
            }
            return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(newRouteValues, ModuleContext)));
        }
        public ActionResult ReturnRoute(string controllerName, string actionName, params string[] querystring)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();

            routeValues["controller"] = controllerName;
            routeValues["action"]     = actionName;
            foreach (var p in querystring)
            {
                var pp = p.Split('=');
                routeValues.Add(pp[0], pp[1]);
            }
            return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));
        }
Beispiel #7
0
        public ActionResult Delete(int id)
        {
            var item = uow.FunctionRepo.GetByID(id);

            uow.FunctionRepo.Delete(item);
            uow.Save();
            uow.Close();
            var routeVals = TypeHelper.ObjectToDictionary(new { projectId = item.ProjectID });

            routeVals["controller"] = "Function";
            routeVals["action"]     = "Index";
            return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext)));
        }
Beispiel #8
0
        private ModuleRequestContext GetModuleRequestContext(HttpContextBase httpContext)
        {
            var module = this.ModuleContext.Configuration;

            // TODO DesktopModuleControllerAdapter usage is temporary in order to make method testable
            var desktopModule  = DesktopModuleControllerAdapter.Instance.GetDesktopModule(module.DesktopModuleID, module.PortalID);
            var defaultControl = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey(string.Empty, module.ModuleDefID);

            var defaultRouteData = ModuleRoutingProvider.Instance().GetRouteData(null, defaultControl);

            var moduleApplication = this.GetModuleApplication(desktopModule, defaultRouteData);

            RouteData routeData;

            var queryString = httpContext.Request.QueryString;

            if (string.IsNullOrEmpty(this._controlKey))
            {
                this._controlKey = queryString.GetValueOrDefault("ctl", string.Empty);
            }

            var moduleId = Null.NullInteger;

            if (queryString["moduleid"] != null)
            {
                int.TryParse(queryString["moduleid"], out moduleId);
            }

            if (moduleId != this.ModuleContext.ModuleId && string.IsNullOrEmpty(this._controlKey))
            {
                // Set default routeData for module that is not the "selected" module
                routeData = defaultRouteData;
            }
            else
            {
                var control = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey(this._controlKey, module.ModuleDefID);
                routeData = ModuleRoutingProvider.Instance().GetRouteData(httpContext, control);
            }

            var moduleRequestContext = new ModuleRequestContext
            {
                DnnPage           = this.Page,
                HttpContext       = httpContext,
                ModuleContext     = this.ModuleContext,
                ModuleApplication = moduleApplication,
                RouteData         = routeData,
            };

            return(moduleRequestContext);
        }
Beispiel #9
0
        private ModuleRequestContext GetModuleRequestContext(HttpContextBase httpContext)
        {
            var module = ModuleContext.Configuration;

            //TODO DesktopModuleControllerAdapter usage is temporary in order to make method testable
            var desktopModule   = DesktopModuleControllerAdapter.Instance.GetDesktopModule(module.DesktopModuleID, module.PortalID);
            var defaultControl  = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey("", module.ModuleDefID);
            var defaultSegments = defaultControl.ControlSrc.Replace(".mvc", "").Split('/');

            var moduleApplication = new ModuleApplication
            {
                DefaultActionName     = defaultSegments[1],
                DefaultControllerName = defaultSegments[0],
                ModuleName            = desktopModule.ModuleName,
                FolderPath            = desktopModule.FolderName
            };

            RouteData routeData;

            if (String.IsNullOrEmpty(_controlKey))
            {
                _controlKey = httpContext.Request.QueryString.GetValueOrDefault("ctl", String.Empty);
            }

            var moduleId = httpContext.Request.QueryString.GetValueOrDefault("moduleId", -1);

            if (moduleId != ModuleContext.ModuleId && String.IsNullOrEmpty(_controlKey))
            {
                //Set default routeData for module that is not the "selected" module
                routeData = new RouteData();
                routeData.Values.Add("controller", defaultSegments[0]);
                routeData.Values.Add("action", defaultSegments[1]);
            }
            else
            {
                var control = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey(_controlKey, module.ModuleDefID);
                routeData = ModuleRoutingProvider.Instance().GetRouteData(httpContext, control);
            }

            var moduleRequestContext = new ModuleRequestContext
            {
                HttpContext       = httpContext,
                ModuleContext     = ModuleContext,
                ModuleApplication = moduleApplication,
                RouteData         = routeData
            };

            return(moduleRequestContext);
        }
        private static string GenerateLink(string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes, ModuleInstanceContext moduleContext)
        {
            routeValues["controller"] = controllerName;
            routeValues["action"]     = actionName;
            string url = ModuleRoutingProvider.Instance().GenerateUrl(routeValues, moduleContext);

            TagBuilder tagBuilder = new TagBuilder("a")
            {
                InnerHtml = (!String.IsNullOrEmpty(linkText)) ? HttpUtility.HtmlEncode(linkText) : String.Empty
            };

            tagBuilder.MergeAttributes(htmlAttributes);
            tagBuilder.MergeAttribute("href", url);
            return(tagBuilder.ToString(TagRenderMode.Normal));
        }
 public ActionResult Create(Documents model, HttpPostedFileBase file, int projectId = 0)
 {
     if (Request.HttpMethod == "GET")
     {
         model.PostDate = DateTime.Now;
         ModelState.Clear();
     }
     else
     {
         //model.PostDate = DateTime.ParseExact(model.PostDateTemp, "dd/MM/yyyy", null);
         if (ModelState.IsValid)
         {
             if (uow.DocumentRepo.GetByProject(projectId).Any(s => s.Document.Name == model.Name))
             {
                 ModelState.AddModelError("", "Document is existed");
                 return(View(model));
             }
             else
             {
                 if (file.ContentLength > 0)
                 {
                     string pathfile = UploadService.Upload(file);
                     if (!string.IsNullOrEmpty(pathfile))  // Upload success
                     {
                         uow.DocumentRepo.Insert(new Documents
                         {
                             ProjectId = model.ProjectId,
                             Name      = Path.GetFileNameWithoutExtension(file.FileName),
                             Path      = pathfile,
                             Extension = Path.GetExtension(file.FileName),
                             PostDate  = DateTime.Now
                         });
                         uow.Save();
                         uow.Close();
                         var routeVals = TypeHelper.ObjectToDictionary(new { });
                         routeVals["controller"] = "Project";
                         routeVals["action"]     = "Detail";
                         var url = ModuleRoutingProvider.Instance().GenerateUrl(routeVals, ModuleContext) + "?id=" + model.ProjectId;
                         return(Redirect(url));
                     }
                     ModelState.AddModelError("", "Upload file fail");
                 }
                 ModelState.AddModelError("", "Cannot upload file have length equal 0 byte");
             }
         }
     }
     return(View(model));
 }
        public ActionResult ReturnRoute(int?id, ActionResult defaultRoute)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();

            switch (GetRouteParameter())
            {
            case "p-v":
                routeValues["controller"] = "Pilot";
                routeValues["action"]     = "View";
                routeValues.Add("UserId", id);
                return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));

            case "home":
                return(RedirectToDefaultRoute());
            }
            return(defaultRoute);
        }
Beispiel #13
0
        private ModuleRequestContext GetModuleRequestContext(HttpContextBase httpContext)
        {
            var module = ModuleContext.Configuration;

            //TODO DesktopModuleControllerAdapter usage is temporary in order to make method testable
            var desktopModule  = DesktopModuleControllerAdapter.Instance.GetDesktopModule(module.DesktopModuleID, module.PortalID);
            var defaultControl = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey("", module.ModuleDefID);

            var defaultRouteData = ModuleRoutingProvider.Instance().GetRouteData(null, defaultControl);

            var moduleApplication = GetModuleApplication(desktopModule, defaultRouteData);

            RouteData routeData;

            if (String.IsNullOrEmpty(_controlKey))
            {
                _controlKey = httpContext.Request.QueryString.GetValueOrDefault("ctl", String.Empty);
            }

            var moduleId = httpContext.Request.QueryString.GetValueOrDefault("moduleId", -1);

            if (moduleId != ModuleContext.ModuleId && String.IsNullOrEmpty(_controlKey))
            {
                //Set default routeData for module that is not the "selected" module
                routeData = defaultRouteData;
            }
            else
            {
                var control = ModuleControlControllerAdapter.Instance.GetModuleControlByControlKey(_controlKey, module.ModuleDefID);
                routeData = ModuleRoutingProvider.Instance().GetRouteData(httpContext, control);
            }

            var moduleRequestContext = new ModuleRequestContext
            {
                DnnPage           = Page,
                HttpContext       = httpContext,
                ModuleContext     = ModuleContext,
                ModuleApplication = moduleApplication,
                RouteData         = routeData
            };

            return(moduleRequestContext);
        }
        public ActionResult ReturnRoute(int?id, ActionResult defaultRoute)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();

            switch (GetRouteParameter())
            {
            case "c-tls":
                routeValues["controller"] = "Conference";
                routeValues["action"]     = "TracksLocationsSlots";
                routeValues.Add("conferenceId", id);
                return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));

            case "c-ss":
                routeValues["controller"] = "Conference";
                routeValues["action"]     = "SessionsSpeakers";
                routeValues.Add("conferenceId", id);
                return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));

            case "c-m":
                routeValues["controller"] = "Conference";
                routeValues["action"]     = "Manage";
                routeValues.Add("conferenceId", id);
                return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));

            case "s-v":
                routeValues["controller"] = "Session";
                routeValues["action"]     = "View";
                routeValues.Add("conferenceId", ControllerContext.HttpContext.Request.Params["ConferenceId"]);
                routeValues.Add("SessionId", id);
                return(Redirect(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, ModuleContext)));

            case "home":
                return(RedirectToDefaultRoute());
            }
            return(defaultRoute);
        }
Beispiel #15
0
 private string GenerateUrl(string actionName, string controllerName, RouteValueDictionary routeValues)
 {
     routeValues["controller"] = controllerName ?? this.controller.ControllerContext?.RouteData.Values["controller"];
     routeValues["action"]     = actionName;
     return(ModuleRoutingProvider.Instance().GenerateUrl(routeValues, this.ModuleContext));
 }