Ejemplo n.º 1
0
        public EditUsersProfileViewModel GetUsersProfileById(int id)
        {
            UMS.Models.EntityModels.Profile userProfile = this.Context.Profiles
                                                          .Where(p => p.Id == id)
                                                          .FirstOrDefault();

            IEnumerable <ProfileMenu> profileMenus = this.Context.ProfileMenus
                                                     .OrderBy(pm => pm.System)
                                                     .ThenBy(pm => pm.Role)
                                                     .ToList();

            IEnumerable <DisplayAllProfileMenus> displayProfileMenus = Mapper.Map <IEnumerable <ProfileMenu>, IEnumerable <DisplayAllProfileMenus> >(profileMenus);

            EditUsersProfileViewModel editUsersProfileView = new EditUsersProfileViewModel
            {
                Id              = userProfile.Id,
                Heading         = userProfile.Heading,
                Direction       = userProfile.Direction,
                Directorate     = userProfile.Directorate,
                Position        = userProfile.Position,
                ProfileMenus    = userProfile.ProfileMenus,
                AllProfileMenus = displayProfileMenus
            };

            return(editUsersProfileView);
        }
Ejemplo n.º 2
0
        public bool SaveData(AddNewProfileViewModel model)
        {
            var direction = model.SelectedDirection;

            if (direction == "--- Изберете стойност ---")
            {
                direction = string.Empty;
            }

            var directorate = model.SelectedDirectorate;

            if (directorate == "--- Изберете стойност ---")
            {
                directorate = string.Empty;
            }

            var profile = new UMS.Models.EntityModels.Profile
            {
                Heading     = model.SelectedHeading,
                Direction   = direction,
                Directorate = directorate,
                Position    = model.SelectedPosition
            };

            if (this.Context.Profiles.Any(p => p.Heading == model.SelectedHeading &&
                                          p.Direction == direction &&
                                          p.Directorate == directorate &&
                                          p.Position == model.SelectedPosition))
            {
                return(false);
            }
            else
            {
                this.Context.Profiles.Add(profile);
                this.Context.SaveChanges();
                return(true);
            }
        }