public ActionResult <Dictionary <int, GroupDetail> > GetAllGroupsDetailByUserId(int userId)
        {
            try
            {
                Dictionary <int, GroupDetail> groupDetails = new Dictionary <int, GroupDetail>();
                DataTable data = DALEasyShare.DataAccess.GetAllGroupsDetailByUserId(userId);

                foreach (DataRow row in data.Rows)
                {
                    if (groupDetails.ContainsKey(Convert.ToInt32(row["GroupId"])))
                    {
                        groupDetails[Convert.ToInt32(row["GroupId"])].TotalSpendInGroup += Convert.ToDecimal(row["Amount"]);
                    }
                    else
                    {
                        GroupDetail group = new GroupDetail();
                        group.GroupName         = row["GroupName"].ToString();
                        group.TotalSpendInGroup = Convert.ToDecimal(row["Amount"]);

                        groupDetails.Add(Convert.ToInt32(row["GroupId"]), group);
                    }
                }

                return(groupDetails);
            }
            catch (Exception ex)
            {
                //log the error for debugging
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 创建新组织
        /// </summary>
        public async Task CreateGroupAsync(GroupDetail groupDetail)
        {
            // 插入组织
            var group = await _groupRepository.InsertAsync(_mapper.Map <G>(groupDetail));

            // 上级组织树节点
            if (!string.IsNullOrEmpty(groupDetail.UpId))
            {
                var upId  = Guid.Parse(groupDetail.UpId);
                var trees = _groupTreeRepository.GetByWhereNoTracking(gt => gt.Descendant == upId);
                foreach (var tree in trees)
                {
                    await _groupTreeRepository.InsertAsync(new GroupTree
                    {
                        Ancestor   = tree.Ancestor,
                        Descendant = group.Id,
                        Length     = tree.Length + 1
                    });
                }
            }

            // 自身组织树节点
            await _groupTreeRepository.InsertAsync(new GroupTree
            {
                Ancestor   = group.Id,
                Descendant = group.Id,
                Length     = 0
            });

            await _unitOfWork.CommitAsync();
        }
        public TaskResult <bool> SaveGroup(GroupDetail group)
        {
            TaskResult <bool> result = null;

            try
            {
                if (group.Id == null)//insert
                {
                    _groupRepository.Insert(new Group {
                        DateCreated = DateTime.Now, Description = group.Description, Name = group.Name
                    });
                    _groupRepository.SaveChanges();
                    result = new TaskResult <bool> {
                        Data = true, state = StatusState.DoneState
                    };
                }
            }
            catch (Exception e)
            {
                Logger.Instance.LogException(e);
                result = new TaskResult <bool> {
                    Data = false, state = StatusState.CancelState
                };
            }
            return(result);
        }
Example #4
0
        public ReportWindow(GroupDetail _GD, ObservableCollection <GridSC> _ListOfGridSC, string No, string Type, string TextAlign, string FontStyle, string FontWeight, string Font)
        {
            InitializeComponent();
            try
            {
                ListOfGridSC = _ListOfGridSC;
                _GroupDetail = _GD;
                NoOfLabel    = No;
                TA           = TextAlign;
                FS           = FontStyle;
                FW           = FontWeight;
                font         = Font;

                if (Type == "L16")
                {
                    FillLable16One();
                }
                else if (Type == "L24")
                {
                    FillLable24One();
                }
                else if (Type == "L18")
                {
                    FillLable18One();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #5
0
        /// <summary>
        /// 更新组织
        /// </summary>
        public async Task UpdateGroupAsync(GroupDetail groupDetail)
        {
            _memoryCache.Remove(groupDetail.Id);

            // 更新
            _groupRepository.Update(_mapper.Map <G>(groupDetail));
            await _unitOfWork.CommitAsync();
        }
Example #6
0
        public GroupViewModel(UserManagementDb userManagementDb, GroupDetail groupDetail)
        {
            this.userManagementDb = userManagementDb;
            this.groupId          = groupDetail.GroupID;
            this.name             = groupDetail.GroupName;

            this.SaveCommand = new RelayCommand(this.ExecuteSaveCommand, this.CanExecuteSaveCommand);
        }
 public void UpdateGroupDetail(Group group, GroupDetail groupDetail)
 {
     if (group == null || !group.Id.Equals(groupDetail.GroupId))
     {
         return;
     }
     _context.Set <GroupDetail>().Update(groupDetail);
     _context.SaveChanges();
 }
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (_selectedIndex < 0)
            {
                MessageBox.Show("Chưa có người được chọn", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            var personId = Int32.Parse(gridView.Rows[_selectedIndex].Cells["Id"].Value.ToString());

            if (_forAttendant)
            {
                if (_attendants.Where(m => m.EmployeeId.Equals(personId)).Any())
                {
                    MessageBox.Show("Nhân viên đã có trong đoàn", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
                if (!_service.CanEmployeeBeAdded(personId, _from, _to))
                {
                    MessageBox.Show("Nhân viên đã tham gia đoàn khác", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
            }
            else
            {
                if (_groupDets.Where(m => m.CustomerId.Equals(personId)).Any())
                {
                    MessageBox.Show("Khách hàng đã có trong đoàn", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
                if (!_service.CanCustomerBeAdded(personId, _from, _to))
                {
                    MessageBox.Show("Khách hàng đã tham gia đoàn khác", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
            }
            var check = MessageBox.Show(confirmMsg, "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (check.Equals(DialogResult.Cancel))
            {
                return;
            }

            if (_forAttendant)
            {
                var jobId = (int)comboJob.SelectedValue;
                var temp  = new Attendant(0, personId, jobId);
                temp.Id = _nextId + 1;
                _attendants.Add(temp);
                _attendantsModified.Add(temp);
            }
            else
            {
                var temp = new GroupDetail(0, personId);
                temp.Id = _nextId + 1;
                _groupDets.Add(temp);
                _groupDetsModified.Add(temp);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 public GroupDetail AddGroupDetail(Group group, GroupDetail groupDetail)
 {
     if (group != null && group.Id.Equals(groupDetail.GroupId))
     {
         var tracked = _context.Set <GroupDetail>().Add(groupDetail);
         _context.SaveChanges();
         return(tracked.Entity);
     }
     return(null);
 }
Example #10
0
        public JsonResult loadChiTiet(string id)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            GroupDetail          gr = db.GroupDetail.Find(id);

            return(Json(new
            {
                data = gr.nhomMa
            }));
        }
 /// <summary>
 /// Show validation card if inputs in task module are not valid.
 /// </summary>
 /// <param name="groupDetail">groupDetail is the values obtained from task module.</param>
 /// <param name="isSplittingValid">split condition valid flag.</param>
 /// <returns>A task that sends validation card in task module.</returns>
 private MessagingExtensionActionResponse ShowValidationForCreateChannel(GroupDetail groupDetail, bool isSplittingValid)
 {
     return(new MessagingExtensionActionResponse
     {
         Task = new TaskModuleContinueResponse
         {
             Value = new TaskModuleTaskInfo
             {
                 Card = GroupActivityCard.GetGroupActivityValidationCard(groupDetail, isSplittingValid),
                 Height = TaskModuleHeight,
                 Width = TaskModuleWidth,
             },
         },
     });
 }
        public JsonResult DeleteGroupDetail(string id)
        {
            FashionShopDbContext db       = new FashionShopDbContext();
            GroupDetail          grDetail = db.GroupDetail.Find(id);

            if (grDetail != null)
            {
                db.GroupDetail.Remove(grDetail);
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
        public JsonResult UpdateGroupDetail(string maLoai, string tenLoai, string tittle, string maNhom)
        {
            FashionShopDbContext db       = new FashionShopDbContext();
            GroupDetail          grDetail = db.GroupDetail.Find(maLoai);

            if (grDetail != null)
            {
                grDetail.tenLoaiSanPham = tenLoai;
                grDetail.meta_tittle    = tittle;
                grDetail.nhomMa         = maNhom;
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Example #14
0
        public static int updateTouchbaseSetting(GroupDetail grp)
        {
            try
            {
                var grpId       = new MySqlParameter("?grpId", grp.GroupId);
                var updateValue = new MySqlParameter("?updateValue", grp.UpdatedValue);
                var mainMstId   = new MySqlParameter("?mainMstId", grp.mainMasterId);

                var Result = _DbTouchbase.ExecuteStoreCommand("CALL USPtouchbase_rowSettings(?grpId,?updateValue,?mainMstId)", grpId, updateValue, mainMstId);

                return(Result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #15
0
 public void save(object pp)
 {
     if (Cansave())
     {
         if (GroupDetail == null)
         {
             GroupDetail             = new GroupDetail();
             GroupDetail.GroupMaster = SelectGroup;
             GroupDetail.Lable1      = Lable1;
             GroupDetail.Lable2      = Lable2;
             GroupDetail.Lable3      = Lable3;
             GroupDetail.Lable4      = Lable4;
             GroupDetail.Lable5      = Lable5;
             GroupDetail.Lable6      = Lable6;
             GroupDetail.Lable7      = Lable7;
             GroupDetail.Lable8      = Lable8;
             GroupDetail.Lable9      = Lable9;
             GroupDetail.Lable10     = Lable10;
             GroupDetail.AddDate     = DateTime.Now;
             GroupDetail.IsDelete    = false;
             _Entities.GroupDetails.Add(GroupDetail);
             _Entities.SaveChanges();
             ListOfGroupD.Insert(0, GroupDetail);
         }
         else
         {
             GroupDetail.GroupMaster            = SelectGroup;
             GroupDetail.Lable1                 = Lable1;
             GroupDetail.Lable2                 = Lable2;
             GroupDetail.Lable3                 = Lable3;
             GroupDetail.Lable4                 = Lable4;
             GroupDetail.Lable5                 = Lable5;
             GroupDetail.Lable6                 = Lable6;
             GroupDetail.Lable7                 = Lable7;
             GroupDetail.Lable8                 = Lable8;
             GroupDetail.Lable9                 = Lable9;
             GroupDetail.Lable10                = Lable10;
             GroupDetail.EditDate               = DateTime.Now;
             _Entities.Entry(GroupDetail).State = EntityState.Modified;
             _Entities.SaveChanges();
             CollectionViewSource.GetDefaultView(ListOfGroupD).Refresh();
             FrmVis = "Hidden";
         }
         Clear(null);
     }
 }
Example #16
0
        private GroupDetail GetGroupDetail(DataSet dataset)
        {
            GroupDetail groupDetail = null;

            if (dataset != null && dataset.Tables.Count > 0)
            {
                DataTable dataTable = dataset.Tables[0];
                if (dataTable != null && dataTable.Rows.Count > 0)
                {
                    groupDetail = new GroupDetail
                    {
                        GroupID   = (int)dataTable.Rows[0].Field <long>("GroupID"),
                        GroupName = dataTable.Rows[0].Field <string>("GroupName")
                    };
                }
            }
            return(groupDetail);
        }
Example #17
0
        private void btnNoPrint_Click(object sender, RoutedEventArgs e)
        {
            GroupDetail _Dm  = dgUsers.SelectedItem as GroupDetail;
            string      Type = Check16.IsChecked == true ? "L16" : "L24";

            if (string.IsNullOrEmpty(txtLabelNo.Text.Trim()))
            {
                CustomDialogBox tempDB = new CustomDialogBox("Enter LabelNo.", DialogType.Information);
                tempDB.ShowDialog();
                txtLabelNo.Focus();
            }
            else
            {
                //ReportWindow _ReportWindow = new ReportWindow(_Dm, txtLabelNo.Text, Type);
                //_ReportWindow.Show();
                //_ReportWindow.Closed += _ReportWindow_Closed;
            }
        }
Example #18
0
        public RequestResponse GetGroupById(int groupId)
        {
            var userMembership = GetUserMembership(groupId);

            if (userMembership == null || !userMembership.IsAccepted)
            {
                return(BadResponse("Invalid permissions."));
            }

            var groupDetail = new GroupDetail(
                userMembership.Group.GroupId,
                userMembership.Group.GroupName,
                userMembership.Group.GroupInviteCode,
                userMembership.IsOfficer,
                userMembership.MemberNickname,
                userMembership.Group.GroupMembers.ToGroupMemberDetailList());

            return(OkModelResponse("Group found.", groupDetail));
        }
Example #19
0
        TaskResult <bool> IGroupDataService.CreateGroup(GroupDetail group)
        {
            TaskResult <bool> result = null;
            HttpClient        client = GetHTTPClient();
            var content = new ObjectContent(typeof(GroupDetail), group, new JsonMediaTypeFormatter());
            HttpResponseMessage response = client.PostAsync("api/Group/CreateGroup", content).Result;

            if (response.IsSuccessStatusCode)
            {
                result = response.Content.ReadAsAsync <TaskResult <bool> >().Result;
            }
            else
            {
                result = new TaskResult <bool> {
                    state = StatusState.CancelState, Data = false
                };
            }
            return(result);
        }
Example #20
0
 public void Delete(object pp)
 {
     if (pp as string == "1")
     {
         if (ListOfGroupD.Where(a => a.IsCheck == true).Count() > 0)
         {
             ObservableCollection <GroupDetail> _GD = new ObservableCollection <GroupDetail>(ListOfGroupD.Where(w => w.IsCheck == true).ToList());
             foreach (GroupDetail item in _GD)
             {
                 item.IsDelete               = true;
                 item.DeleteDate             = DateTime.Now;
                 _Entities.Entry(item).State = EntityState.Modified;
                 _Entities.SaveChanges();
                 _ListOfGroupD.Remove(item);
             }
             CustomDialogBox tempDB = new CustomDialogBox("Successfully Delete.", DialogType.Information);
             tempDB.ShowDialog();
         }
         else
         {
             CustomDialogBox tempDB = new CustomDialogBox("No Date Found.", DialogType.Information);
             tempDB.ShowDialog();
         }
     }
     else
     {
         GroupDetail _DD = pp as GroupDetail;
         if (_DD != null)
         {
             CustomDialogBox tempDB = new CustomDialogBox("Are you sure ?", DialogType.Question);
             bool?           result = tempDB.ShowDialog();
             if (result == true)
             {
                 _DD.IsDelete               = true;
                 _DD.DeleteDate             = DateTime.Now;
                 _Entities.Entry(_DD).State = EntityState.Modified;
                 _Entities.SaveChanges();
                 _ListOfGroupD.Remove(_DD);
             }
         }
     }
 }
Example #21
0
        //private static TouchBaseWebAPI.Data.row_productionEntities _DbTouchbase = new TouchBaseWebAPI.Data.row_productionEntities();

        public static int updateTouchbaseSetting(GroupDetail grp)
        {
            try
            {
                var grpId       = new MySqlParameter("?grpId", grp.GroupId);
                var updateValue = new MySqlParameter("?updateValue", grp.UpdatedValue);
                var mainMstId   = new MySqlParameter("?mainMstId", grp.mainMasterId);

                using (TouchBaseWebAPI.Data.row_productionEntities context = new TouchBaseWebAPI.Data.row_productionEntities())
                {
                    context.Connection.Open();
                    var Result = context.ExecuteStoreCommand("CALL USPtouchbase_rowSettings(?grpId,?updateValue,?mainMstId)", grpId, updateValue, mainMstId);
                    return(Result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #22
0
        //public GroupViewModel(UserManagementDb userManagementDb, GroupDetail groupDetail)
        //{
        //    this.userManagementDb = userManagementDb;
        //    this.groupId = groupDetail.GroupID;
        //    this.name = groupDetail.GroupName;

        //    this.SaveCommand = new RelayCommand(this.ExecuteSaveCommand, this.CanExecuteSaveCommand);

        //    string errorMessage = string.Empty;
        //    var groupDetailDataSet = userManagementDb.GetGroupDetails(groupId, out errorMessage);
        //    var groupFormRights = GetGroupFormRights(groupDetailDataSet);

        //    var formdataset = userManagementDb.LoadComboDetails("FORM", out errorMessage);
        //    var formDetails = GetFormDetails(formdataset);

        //    this.forms = new List<GroupFormViewModel>(formDetails.Select(fd => new GroupFormViewModel(fd.FormID, fd.FormName, this)));
        //    foreach (var form in forms)
        //    {
        //        if (groupFormRights.Any(gfr => gfr.FormID == form.ID))
        //        {
        //            form.IsSelected = true;
        //        }
        //    }
        //}

        public GroupViewModel(UserManagementDb userManagementDb, GroupDetail groupDetail, List <FormDetail> formDetails)
        {
            this.userManagementDb = userManagementDb;
            this.groupId          = groupDetail.GroupID;
            this.name             = groupDetail.GroupName;

            this.SaveCommand = new RelayCommand(this.ExecuteSaveCommand, this.CanExecuteSaveCommand);

            string errorMessage       = string.Empty;
            var    groupDetailDataSet = userManagementDb.GetGroupDetails(groupId, out errorMessage);
            var    groupFormRights    = GetGroupFormRights(groupDetailDataSet);

            this.forms = new List <GroupFormViewModel>(formDetails.Select(fd => new GroupFormViewModel(fd.FormID, fd.CustomeText, this)));
            foreach (var form in forms)
            {
                if (groupFormRights.Any(gfr => gfr.FormID == form.ID))
                {
                    form.IsSelected = true;
                }
            }
        }
Example #23
0
        public void Edit(object pp)
        {
            GroupDetail _DD = pp as GroupDetail;

            if (_DD != null)
            {
                GroupDetail = _DD;
                SelectGroup = _DD.GroupMaster;
                Lable1      = _DD.Lable1;
                Lable2      = _DD.Lable2;
                Lable3      = _DD.Lable3;
                Lable4      = _DD.Lable4;
                Lable5      = _DD.Lable5;
                Lable6      = _DD.Lable6;
                Lable7      = _DD.Lable7;
                Lable8      = _DD.Lable8;
                Lable9      = _DD.Lable9;
                Lable10     = _DD.Lable10;
                FrmVis      = "Visible";
            }
        }
Example #24
0
        /// <summary>
        /// Method sends grouping of members with channels message in teams channel from where it is invoked.
        /// </summary>
        /// <param name="valuesFromTaskModule">Values enter by user in task module.</param>
        /// <param name="membersGroupingWithChannel">A dictionary of members grouped in channels.</param>
        /// <param name="groupActivityCreator">Team owner who initiated the group activity.</param>
        /// <returns>Returns a message to be shown in teams channels.</returns>
        public string GroupingMessage(GroupDetail valuesFromTaskModule, Dictionary <int, IList <TeamsChannelAccount> > membersGroupingWithChannel, string groupActivityCreator)
        {
            try
            {
                StringBuilder groupMessageActivity = new StringBuilder();
                StringBuilder membersName          = new StringBuilder();

                int channelCount = 1;
                foreach (var groups in membersGroupingWithChannel)
                {
                    membersName.Append(" ");
                    string groupTextCounter = $"Group-{channelCount}";
                    string groupName        = $"{valuesFromTaskModule.GroupTitle.Trim()}";

                    // limiting the text content to show till 40 characters in adaptive card
                    string truncatedGroupName = groupName.Length <= TruncateThresholdLength ? groupName : groupName.Substring(0, 40) + "...";
                    foreach (var member in groups.Value)
                    {
                        if (!member.Name.Equals(groupActivityCreator, StringComparison.OrdinalIgnoreCase))
                        {
                            membersName.Append(member.Name).Append(",").Append(" ");
                        }
                    }

                    channelCount++;
                    string groupMessageActivityText = $"**{groupTextCounter}** - **{truncatedGroupName}** :";
                    groupMessageActivity.AppendLine(groupMessageActivityText).AppendLine().AppendLine(membersName.ToString().Trim().TrimEnd(',')).AppendLine();
                    membersName.Clear();
                }

                this.logger.LogInformation($"Grouping message is : {groupMessageActivity.ToString()} ");
                return(groupMessageActivity.ToString());
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, "Error while creating grouping message that is to be posted after grouping.");
                throw;
            }
        }
        /// <summary>
        /// Join group for students
        /// </summary>
        /// <param name="GroupID"></param>
        public void JoinStudentGroup(Guid GroupID)
        {
            using (var db = new MyLearnDBEntitiess())
            {
                var UserId = Guid.Parse(HttpContext.Current.User.Identity.GetUserId());
                var x      = db.GroupDetails.SingleOrDefault(v => v.UserId == UserId && v.GroupId == GroupID);
                if (x == null)
                {
                    GroupDetail group = new GroupDetail();
                    group.Id          = Guid.NewGuid();
                    group.UserId      = UserId;
                    group.GroupId     = GroupID;
                    group.DateCreated = DateTime.Now;
                    group.DateEdited  = DateTime.Now;
                    group.IsEnable    = true;
                    group.IsActive    = true;

                    db.GroupDetails.Add(group);
                    db.SaveChanges();
                }
            }
        }
Example #26
0
        public GroupDetail Get(GroupCriteria criteria)
        {
            var qGroup = View <Group>().All();

            if (criteria.IDToInt > 0)
            {
                qGroup = qGroup.Where(w => w.ID == criteria.IDToInt);
            }

            var group = qGroup.SingleOrDefault();

            if (group == null)
            {
                return(null);
            }

            var groupDetail = new GroupDetail();

            MapProperty(group, groupDetail);

            return(groupDetail);
        }
 public IHttpActionResult CreatingGroup(string GroupName)
 {
     try
     {
         if (GroupName != null)
         {
             var group = new GroupDetail();
             group.GroupName = GroupName;
             db.GroupDetails.Add(group);
             db.SaveChanges();
             return(Ok(group));
         }
         else
         {
             return(Ok("Group Name is required"));
         }
     }
     catch (Exception ex)
     {
         return(NotFound());
     }
 }
        public JsonResult CreateGroupDetail(string maLoai, string tenLoai, string tittle, string manhom)
        {
            FashionShopDbContext db   = new FashionShopDbContext();
            GroupDetail          temp = db.GroupDetail.Find(maLoai);

            if (temp == null)
            {
                var list = db.GroupDetail.Where(x => x.meta_tittle == tittle).ToList();
                if (list.Count() == 0)
                {
                    GroupDetail grDetail = new GroupDetail();
                    grDetail.maLoaiSanPham  = maLoai;
                    grDetail.tenLoaiSanPham = tenLoai;
                    grDetail.meta_tittle    = tittle;
                    grDetail.nhomMa         = manhom;
                    db.GroupDetail.Add(grDetail);
                    db.SaveChanges();
                    return(Json(new
                    {
                        status = 1
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = 3
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = 2
                }));
            }
        }
Example #29
0
        public ActionResult AddStudent(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var group = db.Groups.Find(id);

            if (group == null)
            {
                return(HttpNotFound());
            }

            var groupDetail = new GroupDetail
            {
                GroupId = id.Value,
            };

            ViewBag.UserId = new SelectList(
                db.Users.Where(u => u.IsStudent).OrderBy(u => u.FirstName).ThenBy(u => u.LastName),
                "UserId", "FullName");

            return(View(groupDetail));
        }
Example #30
0
        public ActionResult AddStudent(GroupDetail groupDetail)
        {
            if (ModelState.IsValid)
            {
                var exists = db.GroupDetails
                             .Where(gd => gd.GroupId == groupDetail.GroupId &&
                                    gd.UserId == groupDetail.UserId).FirstOrDefault();

                if (exists == null)
                {
                    db.GroupDetails.Add(groupDetail);
                    db.SaveChanges();
                    return(RedirectToAction(string.Format("Details/{0}", groupDetail.GroupId)));
                }

                ModelState.AddModelError(string.Empty, "Estudiante ya matriculado en este grupo");
            }

            ViewBag.UserId = new SelectList(
                db.Users.Where(u => u.IsStudent).OrderBy(u => u.FirstName).ThenBy(u => u.LastName),
                "UserId", "FullName", groupDetail.UserId);

            return(View(groupDetail));
        }