Example #1
0
        public async Task <ActionResult> Index(int groupId)
        {
            var group = await storyUnitOfWork.Groups.GetGroupByIdAsync(groupId);

            if (group == null)
            {
                ModelState.AddModelError("Group", "The provided interest group does not exist.");
                return(RedirectToAction("Index", new { groupId = 0 }));
            }

            var givingAdviceStories = await storyUnitOfWork.Stories.GetUnpromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.GivingAdvice);

            var askingAdviceStories = await storyUnitOfWork.Stories.GetUnpromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.AskingAdvice);

            var regularStories = await storyUnitOfWork.Stories.GetUnpromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.Regular);

            var pGivingAdviceStories = await storyUnitOfWork.Stories.GetPromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.GivingAdvice);

            var pAskingAdviceStories = await storyUnitOfWork.Stories.GetPromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.AskingAdvice);

            var pRegularStories = await storyUnitOfWork.Stories.GetPromotedStoriesByGroupAndTypeAsync(group.Id, StoryType.Regular);

            var groupVM = new GroupVM()
            {
                Members                     = Mapper.Map <List <UserBasicInfoVM> >(group.Members),
                RegularStories              = Mapper.Map <List <StoryVM> >(regularStories),
                AskingAdviceStories         = Mapper.Map <List <StoryVM> >(askingAdviceStories),
                GivingAdviceStories         = Mapper.Map <List <StoryVM> >(givingAdviceStories),
                PromotedRegularStories      = Mapper.Map <List <StoryVM> >(pRegularStories),
                PromotedAskingAdviceStories = Mapper.Map <List <StoryVM> >(pAskingAdviceStories),
                PromotedGivingAdviceStories = Mapper.Map <List <StoryVM> >(pGivingAdviceStories),
            };

            return(View(groupVM));
        }
Example #2
0
        public ActionResult NewEvent(GroupVM vm)
        {
            var state = "";

            if (!string.IsNullOrWhiteSpace(vm.NewEventName))
            {
                var group = Context.Groups.SingleOrDefault(e => e.Id == vm.Id);
                if (group != null)
                {
                    Context.Events.Add(new Event
                    {
                        EventName    = vm.NewEventName,
                        EventCreator = UserHelper.GetCurrentDbUser(Context),
                        CreatedOn    = DateTime.Now,
                        Group        = group
                    });

                    Context.SaveChanges();
                    state = "success";
                }
                else
                {
                    state = "error";
                }
            }
            else
            {
                state = "error";
            }

            return(RedirectToAction("Details", new { id = vm.Id, state }));
        }
Example #3
0
        public ActionResult Create()
        {
            GroupVM viewModel = new GroupVM();

            viewModel = poulateDropDownList(viewModel);
            return(View(viewModel));
        }
Example #4
0
        public async Task <ActionResult> CreateGroup(GroupVM group)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_AjaxValidation", "Could not create the group."));
            }

            var existingGroup = await storyUnitOfWork.Groups.FindByTitleAsync(group.Title);

            if (existingGroup != null)
            {
                ModelState.AddModelError("GroupTitle", "A group with that title already exists.");
                return(PartialView("_AjaxValidation", "Could not create the group."));
            }

            var groupInfo = Mapper.Map <Group>(group);

            storyUnitOfWork.Groups.InsertOrUpdate(groupInfo);

            var existingHashtag = await storyUnitOfWork.Hashtags.FindByValueAsync(group.Title);

            if (existingHashtag != null)
            {
                storyUnitOfWork.Hashtags.Remove(existingHashtag);
            }
            await storyUnitOfWork.CompleteAsync();

            return(Json(new { location = Url.Action("Dashboard") }));
        }
        public async Task <IActionResult> Create([FromBody] GroupVM data)
        {
            if (data != null)
            {
                try
                {
                    Group group = new Group();
                    group.Name        = data.name;
                    group.City        = data.city;
                    group.State       = data.state;
                    group.Description = data.description;
                    group.UserId      = data.userId;
                    _context.Groups.Add(group);
                    await _context.SaveChangesAsync();

                    int thisGroupId = FindGroupIdByName(data.name);
                    CreateNewGroupMembers(thisGroupId, data.members);
                    AddOrganizerAsMember(thisGroupId, data.userId);
                    return(Ok());
                }
                catch
                {
                    throw new System.Web.Http.HttpResponseException(System.Net.HttpStatusCode.InternalServerError);
                }
            }
            else
            {
                return(NoContent());
            }
        }
Example #6
0
        public async Task <ActionResult> Update(string id)
        {
            var groups         = _groupService.GetAll();
            var lstGroupDetail = new List <GroupVM>();
            var user           = await _userManager.FindByIdAsync(id);

            var groupsOfUser = _groupService.GetGroupIdsByUserId(user.Id);

            foreach (var item in groups)
            {
                var g = new GroupVM();
                g.Id          = item.Id;
                g.Name        = item.Name;
                g.IsCheck     = false;
                g.Descreption = item.Descreption;
                if (groupsOfUser.Any(n => n.GroupId == item.Id))
                {
                    g.IsCheck = true;
                }

                lstGroupDetail.Add(g);
            }
            var model = new UserModelDetail();

            model.User   = user;
            model.Groups = lstGroupDetail;
            return(View(model));
        }
        public IActionResult Edit(string id)
        {
            _GroupVM          = GetGroups().First(p => p.GroupId == id);
            _GroupVM.UserName = SessionValues.UserId;

            return(View(_GroupVM));
        }
Example #8
0
        public JsonResult Update(GroupVM viewModel)
        {
            var clientResult = new JsonData <object>()
            {
            };

            if (viewModel.GroupID == null)
            {
                clientResult.SetClientData("n", "非法参数");
            }
            viewModel.Remark = string.IsNullOrEmpty(viewModel.Remark) ? viewModel.Name : viewModel.Remark;

            if (viewModel.GroupID == viewModel.ParentID)
            {
                clientResult.SetClientData("n", "上级会员组不能是本身会员组");
            }
            else
            {
                services.Command((db) =>
                {
                    db.Update <Group>(new
                    {
                        viewModel.Enable,
                        viewModel.Name,
                        viewModel.ParentID,
                        viewModel.Remark,
                        UpdateTime = DateTime.Now
                    }, u => u.GroupID == viewModel.GroupID);
                    clientResult.SetClientData("y", "操作成功");
                });
            }
            return(Json(clientResult));
        }
Example #9
0
 /// <summary>
 /// Load all data in this ViewModel from local storage such as database
 /// </summary>
 public void Load()
 {
     LocalUserVM.Load();
     ChatVM.Load();
     ContactVM.Load();
     GroupVM.Load();
     SystemVM.Load();
 }
 public IEnumerable <GroupVM> CreateGroup(string dictaatName, GroupVM group)
 {
     _context.DictaatGroup.Add(new DictaatGroup {
         DictaatName = dictaatName, Name = group.GroupName
     });
     _context.SaveChanges();
     return(this.GetGroups(dictaatName));
 }
Example #11
0
        public async Task <IActionResult> DailyExport(DailyExportForm def)
        {
            if (def.GroupId == null)
            {
                return(View());
            }

            if (!await _userService.IsUserInGroup(User.GetUserID(), def.GroupId))
            {
                ViewData["URL"] = Request.Host.ToString() + Request.Path;
                return(View("Unauthorized"));
            }

            string credential_path = @"C:\Users\ghrey\Downloads\ScrumManager-c7ce2bf2810c.json";

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credential_path);

            FirestoreDb db   = FirestoreDb.Create("scrummanager");
            var         data = await db.Collection("groups").Document(def.GroupId).GetSnapshotAsync();

            var group = data.ConvertTo <Group>();

            var groupVM = new GroupVM(group);

            foreach (var u in groupVM.Users)
            {
                if (!u.Value.Roles.Contains("Writer"))
                {
                    continue;
                }
                var logData = await db.Collection("logs")
                              .WhereEqualTo("UserID", u.Key)
                              .WhereGreaterThanOrEqualTo("Date", def.ExportDate.Date.ToUniversalTime().Date)
                              .WhereLessThan("Date", def.ExportDate.Date.AddDays(1).ToUniversalTime().Date)
                              .GetSnapshotAsync();

                var logDoc = logData.FirstOrDefault();

                if (logDoc != null)
                {
                    var log = logDoc.ConvertTo <Log>();
                    groupVM.Logs.Add(log.DocId, log);
                }
                else
                {
                    groupVM.Logs.Add(u.Value.DisplayName, new Log()
                    {
                        UserName = u.Value.DisplayName, UserID = u.Key
                    });
                }
            }

            groupVM.ViewDate = def.ExportDate;

            //groupVM.UserID = User.GetUserID();
            HttpContext.JsReportFeature().Recipe(jsreport.Types.Recipe.ChromePdf);
            return(View(groupVM));
        }
Example #12
0
        public ActionResult Edit(int GroupID)
        {
            var model = new GroupVM()
            {
                TemData = GroupBL.GetGroup(GroupID)
            };

            return(View(model));
        }
Example #13
0
        public MainWindow()
        {
            InitializeComponent();
            this.GroupVM = new GroupVM();
            List <Branch> Branches = new List <Branch>();
            Branch        branch1  = new Branch("050-586-67-18", "Nizami Street");
            Branch        branch2  = new Branch("050-586-67-18", "Koroglu Street");
            Branch        branch3  = new Branch("050-586-67-18", "28 May Street");
            Branch        branch4  = new Branch("050-586-67-18", "N.Narimanov Street");

            Branches.Add(branch1);
            Branches.Add(branch2);
            Branches.Add(branch3);
            Branches.Add(branch4);
            GroupVM.Branches = Branches;

            List <ServiceType> ServiceTypes = new List <ServiceType>();
            ServiceType        serviceType1 = new ServiceType("Programming");
            ServiceType        serviceType2 = new ServiceType("Networking");
            ServiceType        serviceType3 = new ServiceType("Design");
            ServiceType        serviceType4 = new ServiceType("Java");

            ServiceTypes.Add(serviceType1);
            ServiceTypes.Add(serviceType2);
            ServiceTypes.Add(serviceType3);
            ServiceTypes.Add(serviceType4);
            GroupVM.ServiceTypes = ServiceTypes;

            List <Level> Levels = new List <Level>();
            Level        Level1 = new Level("1 Course");
            Level        Level2 = new Level("2 Course");
            Level        Level3 = new Level("3 Course");
            Level        Level4 = new Level("4 Course");

            Levels.Add(Level1);
            Levels.Add(Level2);
            Levels.Add(Level3);
            Levels.Add(Level4);
            GroupVM.Levels = Levels;

            ObservableCollection <Group> Groups = new ObservableCollection <Group>();
            Group group1 = new Group(No++, "AZE-1814", serviceType1, Level1, branch1, "Max 6 people");
            Group group2 = new Group(No++, "AZE-1815", serviceType2, Level2, branch2, "Max 6 people");
            Group group3 = new Group(No++, "AZE-1816", serviceType3, Level3, branch3, "Max 6 people");
            Group group4 = new Group(No++, "AZE-1817", serviceType4, Level4, branch4, "Max 6 people");

            Groups.Add(group1);
            Groups.Add(group2);
            Groups.Add(group3);
            Groups.Add(group4);
            GroupVM.Groups = Groups;

            GroupVM.grid = mainGrid;

            DataContext = GroupVM;
        }
        public IActionResult Details(int id)
        {
            GroupVM groupVM = _groupService.GetGroup(g => g.Id == id);

            if (groupVM != null)
            {
                return(View(groupVM));
            }
            return(View("Error"));
        }
Example #15
0
 public GroupFormVM(GroupVM group)
     : base(group)
 {
     this.group       = group.GroupModel;
     this.Times       = Options.Times;
     this.Instruments = Options.Instruments;
     this.Panels      = Options.Panels;
     this.Geographies = Options.Geographies;
     this.DataSets    = Options.DataSets;
     this.Languages   = Options.Languages;
 }
        public async Task <IActionResult> RemoveAllLocations([FromBody] GroupVM groupMemberLocationVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await _dbRepository.DeleteGroupLocations(groupMemberLocationVM.GroupUid);

            return(Ok());
        }
Example #17
0
        public ActionResult CreateGroup(/*[Bind(Include = "GroupId,Name")]*/ GroupVM group)
        {
            GroupDTO groupDTO = new GroupDTO
            {
                Name = group.Name
            };

            studentsService.CreateGroup(groupDTO);

            return(RedirectToAction("GroupsList"));
        }
        public void TestGroupDAtoVM()
        {
            GroupDA source = new GroupDA {
                GroupID = 1, GroupName = "Under 10s", IsDeleted = false, Athletes = new List <AthleteDA>()
            };

            GroupVM dest = new GroupVM();

            Assert.IsNull(dest.GroupName);
            Mapper.Map(source, dest);
            Assert.AreEqual("Under 10s", dest.GroupName);
        }
Example #19
0
        public OptResult Update(GroupVM vmEditGroup)
        {
            OptResult rst = null;

            //
            var token = base.ParseToken(ActionContext);

            var group = OOMapper.Map <GroupVM, Group>(vmEditGroup);

            rst = _groupSrv.Update(group);

            return(rst);
        }
Example #20
0
        public OptResult Add(GroupVM vmAddGroup)
        {
            OptResult rst  = null;
            Type      type = typeof(GroupVM);

            //
            var token = base.ParseToken(ActionContext);
            var group = OOMapper.Map <GroupVM, Group>(vmAddGroup);

            rst = _groupSrv.Add(group);

            return(rst);
        }
Example #21
0
    private void Group_OnSelect(object sender, System.EventArgs e)
    {
        // Сброс текущего выделения группы
        if (SelectedGroup != null)
        {
            SelectedGroup.SetSelectState(false);
        }

        SelectedGroup = sender as GroupVM;
        SelectedGroup.SetSelectState(true);

        UpdateLocations();
    }
        public IActionResult AddEngineer(string groupId, string engineerId)
        {
            var name = HttpContext.Session.GetString("UserId");

            _GroupVM = GetGroups().FirstOrDefault(p => p.GroupId == groupId);

            if (_GroupVM == null)
            {
                return(RedirectToAction(nameof(Error)));
            }
            _GroupVM.UserName = SessionValues.UserId;

            return(Ok());
        }
        public IActionResult EditGroup([FromBody] GroupVM data)
        {
            var group = _context.Groups.Find(data.groupId);

            group.Name        = data.name;
            group.Description = data.description;
            group.City        = data.city;
            group.State       = data.state;
            _context.Update(group);
            _context.SaveChanges();
            CreateNewGroupMembers(data.groupId, data.members);

            return(Ok());
        }
        public IActionResult Details(string id)
        {
            var name = HttpContext.Session.GetString("UserId");

            _GroupVM = GetGroups().FirstOrDefault(p => p.GroupId == id);

            if (_GroupVM == null)
            {
                return(RedirectToAction(nameof(Error)));
            }
            _GroupVM.UserName = SessionValues.UserId;

            return(View(_GroupVM));
        }
Example #25
0
        public ActionResult SaveGrs(GroupVM Grs)
        {
            List <SessionListnew> list = Session["SesDet"] as List <SessionListnew>;

            if (list == null)
            {
                return(Redirect("Login/InLogin"));
            }
            else
            {
                Grs.CmpyCode = list[0].CmpyCode;
                Grs.UserName = list[0].user_name;
                return(Json(_GrService.SaveGrs(Grs), JsonRequestBehavior.AllowGet));
            }
        }
Example #26
0
 public ActionResult <Group> GetGroup(Guid ID)
 {
     try
     {
         var rs = _groupService.GetByID(ID);
         if (rs == null)
         {
             return(NotFound("ID not found!"));
         }
         GroupVM result = _mapper.Map <GroupVM>(rs);
         return(Ok(result));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Example #27
0
        public void GroupVMTest()
        {
            GroupVM g1 = new GroupVM();

            List <ParticipantGroup> l1 = new List <ParticipantGroup>
            {
                new ParticipantGroup("1", "G_U10", 0)
            };
            List <ParticipantGroup> l2 = new List <ParticipantGroup>
            {
                new ParticipantGroup("2", "G_U12", 0)
            };
            List <ParticipantGroup> l12 = new List <ParticipantGroup>
            {
                new ParticipantGroup("1", "G_U10", 0),
                new ParticipantGroup("2", "G_U12", 1)
            };


            g1.Assign(l1);
            Assert.AreEqual(1, g1.Items.Count);
            Assert.AreEqual("G_U10", g1.Items[0].Name);

            g1.Add(l2);
            Assert.AreEqual(2, g1.Items.Count);
            Assert.AreEqual("G_U10", g1.Items[0].Name);
            Assert.AreEqual("G_U12", g1.Items[1].Name);

            g1.Assign(l1);
            Assert.AreEqual(1, g1.Items.Count);
            Assert.AreEqual("G_U10", g1.Items[0].Name);

            g1.Assign(l12);
            Assert.AreEqual(2, g1.Items.Count);
            Assert.AreEqual("G_U10", g1.Items[0].Name);
            Assert.AreEqual("G_U12", g1.Items[1].Name);

            g1.Assign(l2);
            g1.Merge(l12);
            Assert.AreEqual(2, g1.Items.Count);
            Assert.AreEqual("G_U10", g1.Items[0].Name);
            Assert.AreEqual("G_U12", g1.Items[1].Name);

            g1.Clear();
            Assert.AreEqual(0, g1.Items.Count);
        }
Example #28
0
        public ActionResult Edit(GroupVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    if (ModelState.IsValid)
                    {
                        tbl_Group item = new tbl_Group()
                        {
                            ID          = viewModel.GroupID,
                            GroupType   = viewModel.GroupType,
                            Name        = viewModel.GroupName,
                            Description = viewModel.Description,
                            StartLimit  = viewModel.StartLimit,
                            EndLimit    = viewModel.EndLimit,
                            UpdateDate  = DateTime.Now,
                            UpdateUser  = UserProfile.UserId
                        };

                        CRUDOperation dataOperations = new CRUDOperation();
                        tbl_Group     dbItem         = dataOperations.UpdateGroup(item);
                        if (dbItem != null)
                        {
                            TempData["success"] = "Ok";
                            TempData["message"] = "Məlumatlar uğurla dəyişdirildi";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            TempData["success"] = "notOk";
                            TempData["message"] = "Məlumatlar dəyişdirilərkən xəta baş verdi";
                            return(RedirectToAction("Index"));
                        }
                    }
                }

                throw new ApplicationException("Invalid model");
            }
            catch (ApplicationException ex)
            {
                viewModel = poulateDropDownList(viewModel);
                return(View(viewModel));
            }
        }
Example #29
0
        public ActionResult Edit(int id)
        {
            GroupVM viewModel = new GroupVM();

            viewModel = poulateDropDownList(viewModel);
            CRUDOperation dataOperations = new CRUDOperation();

            tbl_Group tblItem = dataOperations.GetGroupByID(id);

            viewModel.GroupID     = id;
            viewModel.GroupType   = tblItem.GroupType == null?0:(int)tblItem.GroupType;
            viewModel.GroupName   = tblItem.Name;
            viewModel.Description = tblItem.Description;
            viewModel.StartLimit  = tblItem.StartLimit == null?0:(decimal)tblItem.StartLimit;
            viewModel.EndLimit    = tblItem.EndLimit == null?0:(decimal)tblItem.EndLimit;
            return(View(viewModel));
        }
Example #30
0
        public static bool SaveFile(GroupVM group, List <StudyUnitVM> studyUnits, bool queryPathName)
        {
            List <string> usingPathNames = new List <string>();

            foreach (StudyUnitVM studyUnit in studyUnits)
            {
                if (!SaveStudyUnit(studyUnit, queryPathName, usingPathNames))
                {
                    return(false);
                }
            }
            if (group == null)
            {
                return(true);
            }
            return(SaveGroup(group, usingPathNames, queryPathName));
        }