private void UpdateGroupsFromModel(Groups target, GroupsModel source)
 {
     target.GroupId   = source.GroupId;
     target.GroupName = source.GroupName;
     target.GroupType = Convert.ToInt32(source.GroupType);
     target.IsActive  = source.IsActive;
 }
示例#2
0
        public ActionResult GroupsHome()
        {
            GroupsModel objModel = new GroupsModel();

            objModel.groups = objGroupManager.GetAllGroups();
            return(View(objModel));
        }
        /// <summary>
        /// Сохраняет меню карты сайта
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool SavePageGroup(GroupsModel item)
        {
            using (var db = new CMSdb(_context))
            {
                var query = db.core_page_groups
                            .Where(w => w.f_site == _siteId);

                if (query.Where(w => w.id == item.Id).Any())
                {
                    return(query
                           .Set(s => s.c_name, item.Title)
                           .Set(s => s.c_alias, item.Alias.ToLower())
                           .Update() > 0);
                }
                else
                {
                    int sort = query.Any() ? query.Select(s => s.n_sort).Max() : 1;
                    sort++;
                    return(db.core_page_groups.Insert(() => new core_page_groups
                    {
                        id = item.Id,
                        c_name = item.Title,
                        c_alias = item.Alias.ToLower(),
                        f_site = _siteId,
                        n_sort = sort
                    }) > 0);
                }
            }
        }
示例#4
0
        public IGroupsModel GetById(int id)
        {
            GroupsModel group = new GroupsModel();

            using (var db = new SqlCeConnection(connectionString))
            {
                db.Open();
                string query = "select Id, Name, Number, Identifier, AncestorNumber, AncestorIdentifier, ProductType, Link, Notes from Groups where Id=@Id";
                using (SqlCeCommand cmd = new SqlCeCommand(query, db))
                {
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@Id", id);
                    using (SqlCeDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            group.Id                 = Convert.ToInt32(reader["Id"]);
                            group.Name               = reader["Name"].ToString();
                            group.Number             = reader["Number"].ToString();
                            group.Identifier         = reader["Identifier"].ToString();
                            group.AncestorNumber     = reader["AncestorNumber"].ToString();
                            group.AncestorIdentifier = reader["AncestorIdentifier"].ToString();
                            group.ProductType        = reader["ProductType"].ToString();
                            group.Link               = reader["Link"].ToString();
                            group.Notes              = reader["Notes"].ToString();
                        }
                    }
                }
                db.Close();
            }
            return(group);
        }
示例#5
0
        public IEnumerable <IGroupsModel> GetAll()
        {
            var    listgroupsModel = new List <GroupsModel>();
            string query           = "select * from Groups";

            using (var db = new SqlCeConnection(connectionString))
            {
                db.Open();
                using (SqlCeCommand command = new SqlCeCommand(query, db))
                {
                    using (SqlCeDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            GroupsModel group = new GroupsModel
                            {
                                Id                 = Convert.ToInt32(reader["Id"]),
                                Name               = reader["Name"].ToString(),
                                Number             = reader["Number"].ToString(),
                                Identifier         = reader["Identifier"].ToString(),
                                AncestorNumber     = reader["AncestorNumber"].ToString(),
                                AncestorIdentifier = reader["AncestorIdentifier"].ToString(),
                                ProductType        = reader["ProductType"].ToString(),
                                Link               = reader["Link"].ToString(),
                                Notes              = reader["Notes"].ToString()
                            };
                            listgroupsModel.Add(group);
                        }
                    }
                }
                db.Close();
            }
            return(listgroupsModel);
        }
示例#6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtGroup.Text) || GroupId == 0)
            {
                MessageBox.Show("Please select Group first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                initForm();
            }
            else
            {
                ActionResult deleteResult = formCtrl._deleteFormData(new GroupsModel()
                {
                    GroupId = GroupId
                });

                if (deleteResult.State)
                {
                    GroupsModel deleteObj = deleteResult.Data;
                    MessageBox.Show("Group " + deleteObj.GroupName + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initForm();
                }
                else
                {
                    MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public virtual IActionResult Update(GroupsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            {
                return(AccessDeniedView());
            }

            var entity = _gpRepository.Table.Where(x => x.Id == model.Id).FirstOrDefault();

            if (entity != null)
            {
                entity.GroupName    = model.GroupName;
                entity.Interval     = model.Interval;
                entity.Percentage   = model.Percentage;
                entity.UpdatedOnUtc = DateTime.UtcNow;

                _gpRepository.Update(entity);
            }
            //var group = model.ToEntity();
            //group.CreatedOnUtc = DateTime.UtcNow;
            //group.UpdatedOnUtc = DateTime.UtcNow;

            //_gpRepository.Update(group);



            return(Json(model));
        }
示例#8
0
        public ActionResult Index()
        {
            GroupsModel model = new GroupsModel();

            List <StopDto>  stops  = this.stopService.GetUnresolved();
            List <GroupDto> groups = this.groupService.GetGroups();

            Dictionary <Guid, StopDto> stopHash = new Dictionary <Guid, StopDto>();

            if (stops != null)
            {
                stopHash = stops.ToDictionary(x => x.GroupId);
            }

            List <Model> groupModels = new List <Model>();

            foreach (GroupDto group in groups)
            {
                Model groupModel = Mapper.Map <GroupDto, Model>(group);
                if (stopHash.ContainsKey(group.Id))
                {
                    groupModel.State = State.Stopped;
                }
                groupModels.Add(groupModel);
            }

            model.Groups = groupModels;

            return(View(model));
        }
示例#9
0
 public GroupsViewModel()
 {
     this.context = new TimetableCourseProject();
     context.Groups.Load();
     GroupsDatabase = context.Groups.Local;
     Groups         = new ObservableCollection <Groups>(GroupsDatabase);
     groupModel     = new GroupsModel();
 }
示例#10
0
        public Object CommitLog()
        {
            Object         result = "MvcApplication2.Areas.Items.Controllers.GroupsController.CommitLog()";
            RequestPackage rqp    = RequestPackage.ParseRequest(Request.InputStream, Request.ContentEncoding);
            GroupsModel    m      = new GroupsModel();

            m.CommitLog(rqp);
            return(result);
        }
 public void Edit(Window window)
 {
     IsInProgress = true;
     new Thread(() =>
     {
         EditGroup = new GroupsModel()
         {
             GName        = GroupName,
             GDescription = GroupDescription
         };
         EditGroup.GId        = Group.GId;
         var groupChangeValue = 0;
         try
         {
             groupChangeValue = DataAccess.UpdateGroup(Group.GId, EditGroup);
         }
         catch { MessageBox.Show("Some Thing went Wrong!\nCould not Edit the group\nCheack you internet or server connection", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
         if (groupChangeValue == 1)
         {
             var r = DataAccess.DeleteGroupRoles(Group.GId);
             foreach (var item in DataGridSource)
             {
                 if (item.RoleSelected())
                 {
                     try
                     {
                         DataAccess.InsertGroupeRole(out var id, new GroupRolesModel()
                         {
                             GrolrRoleIdFk = item.RoleId,
                             GrolrGIdFk    = Group.GId,
                             GroleAdd      = item.GroleAdd,
                             GroleEdit     = item.GroleEdit,
                             GroleDelete   = item.GroleDelete,
                             GroleView     = item.GroleView,
                             GrolePrint    = item.GrolePrint,
                             GroleExport   = item.GroleExport
                         });
                     }
                     catch { MessageBox.Show($"some thing went wrong!\nFild to add {{{item.RoleName}}} to {{{EditGroup.GName}}}", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }
                 }
             }
             IsInProgress = false;
             App.Current.Dispatcher.Invoke((Action) delegate
             {
                 window.DialogResult = true;
                 window.Close();
             });
         }
         else
         {
             MessageBox.Show("Field to Edit Group !!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     })
     {
         IsBackground = true
     }.Start();
示例#12
0
        public Object UpsertGroup()
        {
            Object         result = "AreasItems.Areas.Items.Controllers.GroupsController.UpsertGroup()";
            RequestPackage rqp    = RequestPackage.ParseRequest(Request.InputStream, Request.ContentEncoding);
            GroupsModel    m      = new GroupsModel();

            m.UpsertGroup(rqp);
            result = PartialView("~/Areas/Items/Views/Groups/GroupPart.cshtml", m);
            return(result);
        }
        public void Update(int groupsId, GroupsModel groups)
        {
            var result = _context.Groups.SingleOrDefault(x => x.GroupID == groupsId);

            if (result != null)
            {
                result.NameOfGroup = groups.NameOfGroup;
                _context.SaveChanges();
            }
        }
示例#14
0
        public Object SelectGroup()
        {
            Object         result = "MvcApplication2.Areas.Items.Controllers.GroupsController.SelectGroup()";
            RequestPackage rqp    = RequestPackage.ParseRequest(Request.InputStream, Request.ContentEncoding);
            GroupsModel    m      = new GroupsModel();

            m.SelectGroup(rqp);
            result = PartialView("~/Areas/Items/Views/Groups/TableForItemsInGroup.cshtml", m);
            return(result);
        }
示例#15
0
        public void GroupsModelConstructorTest()
        {
            MxUser      user      = null;         // TODO: Initialize to an appropriate value
            string      groupId   = string.Empty; // TODO: Initialize to an appropriate value
            string      groupName = string.Empty; // TODO: Initialize to an appropriate value
            bool        adding    = false;        // TODO: Initialize to an appropriate value
            GroupsModel target    = new GroupsModel(user, groupId, groupName, adding);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
示例#16
0
 public ActionResult DeleteFilterTreeItem(GroupsModel item)
 {
     switch (item.Section)
     {
     case "pages":
         _cmsRepository.DeletePageGroup(item.Id);
         break;
     }
     return(Redirect($"/admin/{item.Section}"));
 }
        public static int InsertGroup(out long insertId, GroupsModel group)
        {
            var changedCount = Insert(out insertId, GroupsTable.TableName, new ParamtersMap
            {
                [GroupsTable.GName]        = group.GName,
                [GroupsTable.GDescription] = group.GDescription
            });

            return(changedCount);
        }
        public async Task <int> DeleteGroupsAsync(GroupsModel model)
        {
            var Groups = new Groups {
                GroupId = model.GroupId
            };

            using (var dataService = DataServiceFactory.CreateDataService())
            {
                return(await dataService.DeleteGroupsAsync(Groups));
            }
        }
        private GroupsView CreateGroupsView()
        {
            IGroupsModel     model     = new GroupsModel();
            IGroupsView      view      = new GroupsView();
            IGroupsPresenter presenter = SimpleResolver.Instance.Get <IGroupsPresenter>(
                new object[] { model, view }
                );

            view.ShowView();
            return(view as GroupsView);
        }
示例#20
0
        public static Groups ToEntity(this GroupsModel model, Groups destination)
        {
            destination.GroupName = model.GroupName;
            // destination.Id = model.Id;
            destination.Interval     = model.Interval;
            destination.Percentage   = model.Percentage;
            destination.CreatedOnUtc = model.CreatedOnUtc;
            destination.UpdatedOnUtc = model.UpdatedOnUtc;

            return(destination);
            //return model.MapTo(destination);
        }
示例#21
0
        public Object Index()
        {
            if (Request.Path != "/Items/Groups")
            {
                throw new ArgumentException();
            }
            Object      result = "MvcApplication2.Areas.Items.Controllers.GroupsController.Index()";
            GroupsModel m      = new GroupsModel();

            result = PartialView("~/Areas/Items/Views/Groups/Index.cshtml", m);
            return(result);
        }
        public static GroupsModel CreateGroupsModelAsync(Groups source, bool includeAllFields)
        {
            var model = new GroupsModel()
            {
                GroupId       = source.GroupId,
                GroupName     = source.GroupName,
                GroupType     = source.GroupType.ToString(),
                IsActive      = source.IsActive,
                GroupTypeName = (source.GroupType == 1)?"Party":"Vendor"
            };

            return(model);
        }
示例#23
0
        public async Task GroupsSave(GroupsModel model)
        {
            ContactsModel alreadyExists = await this.ContactsGetById(model.Id);

            if (alreadyExists == null)
            {
                await AddEntity <GroupsEntity, GroupsModel>(model);
            }
            else
            {
                await this.SaveEntity <GroupsEntity, GroupsModel>(model);
            }
        }
示例#24
0
        public ActionResult Add()
        {
            MxUser mxUser = GetMxUser();

            if (mxUser.IsInRole("GROUP_Add"))
            {
                var model = new GroupsModel(GetMxUser(), true);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("NoAccess", "Account", new { returnUrl = "Admin/Groups" }));
            }
        }
示例#25
0
        public ActionResult Edit(string groupId, string groupName, string add)
        {
            bool   adding = bool.Parse(add);
            MxUser mxUser = GetMxUser();

            if (mxUser.IsInRole("GROUP_View") || mxUser.IsInRole("GROUP_Add") || mxUser.IsInRole("GROUP_Edit") || mxUser.IsInRole("GROUP_Delete"))
            {
                var model = new GroupsModel(GetMxUser(), groupId, groupName, adding);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("NoAccess", "Account", new { returnUrl = "Admin/Groups" }));
            }
        }
示例#26
0
 private void groupAdd_Method(object obj)
 {
     if (IsValid(ValidatesAddProperties, out AddErrors))
     {
         AddErrors += groupModel.Add(GroupsModel.getGroupObject(AddId,
                                                                context.Specialities.Where(s => s.ShortName.Equals(AddSpeciality)).First().Code,
                                                                int.Parse(AddCourse), int.Parse(AddNumber), int.Parse(AddCount)));
         MessageBox.Show(AddErrors, "Результат добавления");
         FilterGroups();
     }
     else
     {
         MessageBox.Show("Заполните поля корректно!", "Результат добавления");
     }
 }
示例#27
0
        /// <summary>
        /// Повертає список усіх груп
        /// </summary>
        /// <returns>Список груп</returns>
        public IEnumerable <IGroupsModel> GetAll()
        {
            var listgroupsModel = new List <GroupsModel>();

            using (var db = new SqlCeConnection(connectionString))
            {
                try
                {
                    db.Open();
                }
                catch (SqlCeException)
                {
                    throw new Exception("Немає підключення до бази даних.");
                }

                string query = "select * from Groups";
                using (SqlCeCommand command = new SqlCeCommand(query, db))
                {
                    try
                    {
                        using (SqlCeDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                GroupsModel group = new GroupsModel
                                {
                                    Id                 = Convert.ToInt32(reader["Id"]),
                                    Name               = reader["Name"].ToString(),
                                    Number             = reader["Number"].ToString(),
                                    Identifier         = reader["Identifier"].ToString(),
                                    AncestorNumber     = reader["AncestorNumber"].ToString(),
                                    AncestorIdentifier = reader["AncestorIdentifier"].ToString(),
                                    ProductType        = reader["ProductType"].ToString(),
                                    Link               = reader["Link"].ToString(),
                                    Notes              = reader["Notes"].ToString()
                                };
                                listgroupsModel.Add(group);
                            }
                        }
                    }
                    catch (SqlCeException)
                    {
                        throw new Exception("Помилка отримання списку груп з бази даних.");
                    }
                }
            }
            return(listgroupsModel);
        }
示例#28
0
        public ActionResult AddFilterTree(string section, string id)
        {
            var model = new GroupsModel();

            if (id != null)
            {
                switch (section)
                {
                case "pages":
                    model = _cmsRepository.GetPageGroup(Guid.Parse(id));
                    break;
                }
            }
            model.Section = section;
            return(PartialView("FilterTreeItem", model));
        }
示例#29
0
 protected void GroupItemChanging(GroupsModel newValue)
 {
     if (newValue != null)
     {
         GroupRolesSource.Clear();
         var roles = GroupRoles.Where(x => x.GrolrGIdFk == newValue.GId);
         foreach (var item in roles)
         {
             var role = Roles.Where(x => x.RoleId == item.GrolrRoleIdFk).FirstOrDefault();
             if (role != null)
             {
                 GroupRolesSource.Add(role.FillRoles(item));
             }
         }
     }
 }
        public async Task <int> UpdateGroupsAsync(int groupId, GroupsModel model)
        {
            using (var dataService = DataServiceFactory.CreateDataService())
            {
                var Groups = groupId > 0 ? await dataService.GetGroupsAsync(model.GroupId) : new Groups();

                if (Groups != null)
                {
                    UpdateGroupsFromModel(Groups, model);
                    await dataService.UpdateGroupsAsync(groupId, Groups);

                    model.Merge(await GetGroupsAsync(dataService, Groups.GroupId));
                }
                return(0);
            }
        }
 private GroupsView CreateGroupsView()
 {
     IGroupsModel model = new GroupsModel();
     IGroupsView view = new GroupsView();
     IGroupsPresenter presenter = SimpleResolver.Instance.Get<IGroupsPresenter>(
         new object[] { model, view }
     );
     view.ShowView();
     return view as GroupsView;
 }