Пример #1
0
        public ActionResult SaveProjectAttribute(ProjectAttributeModel viewModel)
        {
            ProjectAttribute projectAttribute = (viewModel.Id > 0) ? ProjectAttributeRepository.Get(viewModel.Id) :  new ProjectAttribute();

            projectAttribute.Attributeid    = viewModel.Id;
            projectAttribute.ProjectId      = viewModel.ProjectId;
            projectAttribute.Attributename  = viewModel.Name;
            projectAttribute.Attributevalue = viewModel.Value == null ? string.Empty : viewModel.Value;

            if (viewModel.Id == 0)
            {
                projectAttribute.Attributeorder = ProjectAttributeRepository.GetNextAttributeOrderNumber(viewModel.ProjectId);
            }

            int id = ProjectAttributeRepository.Create(projectAttribute);

            if (id > 0)
            {
                ProjectAdminAppModel model = new ProjectAdminAppModel();
                model.ProjectAttributes = ProjectAttributeRepository.GetAll(viewModel.ProjectId);

                return(JsonSuccess(new
                {
                    Html = RenderPartialViewToString(this, AppManager.Instance.GetAppUrl(Constants.AppId, "views/_ProjectAttributes.cshtml"), model)
                }));
            }
            else
            {
                return(JsonError());
            }
        }
Пример #2
0
        public ActionResult ResequenceAttribute(int projectId, int id, int afterid, int newIndex, int oldIndex)
        {
            var projectAttributes = ProjectAttributeRepository.GetAll(projectId);

            ProjectAttribute entity = projectAttributes.Find(s => s.Attributeid == id);

            projectAttributes.RemoveAll(s => s.Attributeid == id);

            if (newIndex > -1)
            {
                projectAttributes.Insert(newIndex, entity);
            }

            int order = 1;

            projectAttributes.ForEach(s => s.Attributeorder = order++);
            projectAttributes.ForEach(s => ProjectAttributeRepository.Create(s));

            return(JsonSuccess());
        }