private void DlgSelectGroups_Loaded(object sender, RoutedEventArgs e) { try { Title = PNLang.Instance.GetControlText(Name, "Contacts groups"); PNLang.Instance.ApplyControlLanguage(this); if (PNStatic.Contacts.Any(c => c.GroupID == -1)) { var gr = new _Group { Name = "(None)", ID = -1 }; var item = new PNListBoxItem(null, gr.Name, gr, gr.Name, false); item.ListBoxItemCheckChanged += item_ListBoxItemCheckChanged; lstGroups.Items.Add(item); } foreach (var cg in PNStatic.ContactGroups.Where(cg => PNStatic.Contacts.Any(c => c.GroupID == cg.ID))) { var gr = new _Group { Name = cg.Name, ID = cg.ID }; var item = new PNListBoxItem(null, gr.Name, gr, gr.Name, false); item.ListBoxItemCheckChanged += item_ListBoxItemCheckChanged; lstGroups.Items.Add(item); } } catch (Exception ex) { PNStatic.LogException(ex); } }
public ActionResult _CreateGroup() { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.IsDeleted == false).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName"); var model = new _Group(); model.Status = true; return(PartialView(model)); }
public ActionResult CreateGroup() { var model = new _Group(); model.Status = true; model.DateFormatForClientSide = ConfigurationManager.AppSettings["dateformatForCalanderClientSide"].ToString(); // sets the client side date format. ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.ExpiryDate >= DateTime.Now && org.IsDeleted == false).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName"); return(View(model)); }
public void StringsDemonstration() { var loData = Defaults.IEnumerable.Filled.String; var loContext = new _Context(); var loWalker = new DSE.Extensions.EnumerableWalker <String, _Context>(loData, loContext); var lsTestValueOnBegin = "Begin"; var lsTestValueOnEnd = "End"; var loTestGroup = new _Group(); loWalker .OnBegin(_ => { _.SaltBefore = lsTestValueOnBegin; _.CountBefore++; }) .OnItem((_, s) => { _.Count++; _.Items.Add(s); }) .OnGroup(loTestGroup, (c, g, s) => !String.IsNullOrEmpty(s) && (s[0] == '2'), (c, g, s) => g.CountBefore++, (c, g) => g.CountAfter++) .OnEnd(_ => { _.SaltAfter = lsTestValueOnEnd; _.CountAfter++; }) .Walk(); Assert.AreEqual(loContext.CountBefore, 1); Assert.AreEqual(loContext.SaltBefore, lsTestValueOnBegin); Assert.AreEqual(loContext.CountAfter, 1); Assert.AreEqual(loContext.SaltAfter, lsTestValueOnEnd); var loTestList = new List <String>(); var lnGroupHit = 0; foreach (var loItem in loData) { loTestList.Add(loItem); } Assert.AreEqual(loContext.Count, loTestList.Count); for (var i = 0; i < loTestList.Count; i++) { var lsValue = loTestList[i]; Assert.AreEqual(lsValue, loContext.Items[i]); if (!String.IsNullOrEmpty(lsValue) && lsValue[0] == '2') { lnGroupHit++; } } Assert.AreEqual(loTestGroup.CountBefore, lnGroupHit); Assert.AreEqual(loTestGroup.CountAfter, lnGroupHit); }
public ActionResult _CreateGroup(_Group gr) { if (ModelState.IsValid) // model validation { var checkGroupName = db.Groups.Where(grp => grp.GroupName.TrimEnd().TrimStart().ToLower() == gr.GroupName.TrimEnd().TrimStart().ToLower()).Select(grp => grp).SingleOrDefault(); if (checkGroupName == null) // check the duplicate name for group { Group grp = new Group(); grp.Status = true; grp.GroupName = gr.GroupName; grp.GroupDescription = gr.GroupDescription; grp.GroupManager = gr.GroupManager; grp.EmailAddress = gr.EmailAddress; grp.ContactNo = gr.ContactNo; grp.CreationDate = DateTime.Now; grp.CreatedById = Convert.ToInt64(Session["UserID"]); grp.IsDeleted = false; db.Groups.Add(grp); db.SaveChanges(); // save th group data in database GroupInfo grInfo = new GroupInfo(); // create group info record grInfo.GroupID = grp.GroupID; grInfo.LanguageId = db.InstanceInfoes.Find(1).DefaultLanguage; grInfo.GroupName = grp.GroupName; grInfo.GroupDescription = gr.GroupDescription; grInfo.GroupManager = grp.GroupManager; grInfo.EmailAddress = grp.EmailAddress; grInfo.ContactNo = grp.ContactNo; grInfo.CreatedById = grp.CreatedById; grInfo.CreationDate = grp.CreationDate; db.GroupInfoes.Add(grInfo); db.SaveChanges(); return(Json(new { success = true, msg = grp.GroupName, gid = grp.GroupID })); } else // return model with error message { ModelState.AddModelError("GroupName", LMSResourse.Admin.Group.errDupGroup); return(Json(new { success = false, msg = "Astrix (*) fields are required. " })); } } ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.IsDeleted == false).Select(org => org), "OrganisationID", "OrganisationName"); return(Json(new { success = false, msg = JsonConvert.SerializeObject(ModelState.Where(a => a.Value.Errors.Count() > 0).ToList()) })); //return PartialView(gr); }
public void StringsDemonstration() { var loData = Defaults.IEnumerable.Filled.String; var loContext = new _Context(); var loWalker = new DSE.Extensions.EnumerableWalker<String, _Context>(loData, loContext); var lsTestValueOnBegin = "Begin"; var lsTestValueOnEnd = "End"; var loTestGroup = new _Group(); loWalker .OnBegin(_ => { _.SaltBefore = lsTestValueOnBegin; _.CountBefore++; }) .OnItem((_, s) => { _.Count++; _.Items.Add(s); }) .OnGroup(loTestGroup, (c, g, s) => !String.IsNullOrEmpty(s) && (s[0] == '2'), (c, g, s) => g.CountBefore++, (c, g) => g.CountAfter++) .OnEnd(_ => { _.SaltAfter = lsTestValueOnEnd; _.CountAfter++; }) .Walk(); Assert.AreEqual(loContext.CountBefore, 1); Assert.AreEqual(loContext.SaltBefore, lsTestValueOnBegin); Assert.AreEqual(loContext.CountAfter, 1); Assert.AreEqual(loContext.SaltAfter, lsTestValueOnEnd); var loTestList = new List<String>(); var lnGroupHit = 0; foreach (var loItem in loData) loTestList.Add(loItem); Assert.AreEqual(loContext.Count, loTestList.Count); for (var i = 0; i < loTestList.Count; i++) { var lsValue = loTestList[i]; Assert.AreEqual(lsValue, loContext.Items[i]); if (!String.IsNullOrEmpty(lsValue) && lsValue[0] == '2') { lnGroupHit++; } } Assert.AreEqual(loTestGroup.CountBefore, lnGroupHit); Assert.AreEqual(loTestGroup.CountAfter, lnGroupHit); }
private static int sys_getgrnam (string name, out _Group group) { throw new System.NotImplementedException(); }
private static extern int sys_fgetgrent (IntPtr stream, out _Group grbuf);
private static extern int sys_getgrent (out _Group grbuf);
private static int sys_getgrgid(uint uid, out _Group group) { throw new System.NotImplementedException(); }
private static extern int sys_getgrnam_r ( [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] string name, out _Group grbuf, out IntPtr grbufp);
private static int sys_fgetgrent (IntPtr stream, out _Group grbuf) { throw new System.NotImplementedException(); }
private static int sys_getgrgid_r (uint uid, out _Group grbuf, out IntPtr grbufp) { throw new System.NotImplementedException(); }
private static void CopyGroup (Group to, ref _Group from) { try { to.gr_gid = from.gr_gid; to.gr_name = UnixMarshal.PtrToString (from.gr_name); to.gr_passwd = UnixMarshal.PtrToString (from.gr_passwd); to.gr_mem = UnixMarshal.PtrToStringArray (from._gr_nmem_, from.gr_mem); } finally { Stdlib.free (from.gr_mem); Stdlib.free (from._gr_buf_); from.gr_mem = IntPtr.Zero; from._gr_buf_ = IntPtr.Zero; } }
private static int sys_fgetgrent(IntPtr stream, out _Group grbuf) { throw new System.NotImplementedException(); }
private static int sys_getgrent(out _Group grbuf) { throw new System.NotImplementedException(); }
private static int sys_getgrgid_r(uint uid, out _Group grbuf, out IntPtr grbufp) { throw new System.NotImplementedException(); }
private static int sys_getgrnam_r( string name, out _Group grbuf, out IntPtr grbufp) { throw new System.NotImplementedException(); }
private static int sys_getgrgid (uint uid, out _Group group) { throw new System.NotImplementedException(); }
private static int sys_getgrnam_r ( string name, out _Group grbuf, out IntPtr grbufp) { throw new System.NotImplementedException(); }
private static extern int sys_getgrgid_r (uint uid, out _Group grbuf, out IntPtr grbufp);
private static int sys_getgrent (out _Group grbuf) { throw new System.NotImplementedException(); }
/// <summary> /// http get method of edit group /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult EditGroup(int id = 0) { _Group gr = new _Group(); Group grp = db.Groups.Find(id); if (grp == null) { return(HttpNotFound()); } else { gr.GroupID = grp.GroupID; gr.Status = grp.Status; gr.GroupName = grp.GroupName; gr.GroupDescription = grp.GroupDescription; gr.GroupManager = grp.GroupManager; gr.EmailAddress = grp.EmailAddress; gr.ContactNo = grp.ContactNo; gr.OrganisationID = grp.OrganisationID; gr.MaxUsers = grp.MaxUsers; var currentLoginUser = Convert.ToInt64(Session["UserID"].ToString()); if ((Session["UserRoles"].ToString()).Split(',').Select(int.Parse).ToArray().Contains(2)) { var GroupAdminGroups = db.UserGroups.Where(x => x.UserId == currentLoginUser).Select(x => x.GroupID).ToList(); if (!GroupAdminGroups.Contains(grp.GroupID)) { return(RedirectToAction("Index", "Groups")); } } if (grp.OrganisationID != null) { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.IsDeleted == false).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName", grp.OrganisationID); } else { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.IsDeleted == false).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName"); } if (grp.OrganisationID != null) { // check is this group is the last group which is assigned to organisation if yes then it can't be updated as this is the last group which is assigned to this organisation. var OrgCount = db.Groups.Where(x => x.OrganisationID == grp.OrganisationID && grp.IsDeleted == false).Count(); if (OrgCount == 1) { ViewBag.IsOrgBlock = "1"; } else { ViewBag.IsOrgBlock = "0"; } // check is this group have any user which is active or inactive then it can't be updated else it can me moved to any organisation. var UserCount = db.UserGroups.Where(x => x.UserProfile.IsDelete == false).Count(); if (UserCount > 0) { ViewBag.IsOrgBlock = "1"; } } else { ViewBag.IsOrgBlock = "0"; } } return(View(gr)); }
protected override void DataUpdate() { System.IO.BinaryReader BSReader = new System.IO.BinaryReader(ByteStream); ByteStream.Position = 0; SubModels = BSReader.ReadInt32(); SubModel = new _SubModel[SubModels]; for (int i = 0; i < SubModels; i++) { _SubModel withBlock = SubModel[i]; withBlock.Vertexes = BSReader.ReadInt32(); withBlock.BlockSize = BSReader.ReadUInt32(); withBlock.k = BSReader.ReadUInt16(); withBlock.c = BSReader.ReadUInt16(); int cnt, offset; cnt = 0; offset = (int)ByteStream.Position; withBlock.Null1 = BSReader.ReadUInt32(); withBlock.Something = BSReader.ReadUInt32(); withBlock.Null2 = BSReader.ReadUInt32(); while ((cnt < withBlock.Vertexes) && (ByteStream.Position < offset + withBlock.BlockSize)) { var withBlock1 = new _Group(); Array.Resize(ref withBlock1.UV, 0); Array.Resize(ref withBlock1.Shit, 0); withBlock1.SomeNum1 = BSReader.ReadUInt32(); withBlock1.Vertexes = BSReader.ReadByte(); cnt += withBlock1.Vertexes; withBlock1.Some80h = BSReader.ReadByte(); withBlock1.Null1 = BSReader.ReadUInt16(); withBlock1.SomeNum2 = BSReader.ReadUInt32(); withBlock1.SomeNum3 = BSReader.ReadUInt32(); withBlock1.Null2 = BSReader.ReadUInt32(); withBlock1.Signature1 = BSReader.ReadUInt32(); withBlock1.SomeShit1 = BSReader.ReadUInt32(); withBlock1.SomeShit2 = BSReader.ReadUInt32(); withBlock1.SomeShit3 = BSReader.ReadUInt32(); withBlock1.Signature2 = BSReader.ReadUInt32(); uint head = BSReader.ReadUInt32(); while (head != 335544320) { switch (head & 255) { case 3: { withBlock1.VertHead = head; withBlock1.Vertex = new Position3[withBlock1.Vertexes]; for (int j = 0; j <= withBlock1.Vertexes - 1; j++) { withBlock1.Vertex[j].X = BSReader.ReadSingle(); withBlock1.Vertex[j].Y = BSReader.ReadSingle(); withBlock1.Vertex[j].Z = BSReader.ReadSingle(); } break; } case 4: { withBlock1.WeightHead = head; withBlock1.Weight = new _Weight[withBlock1.Vertexes]; for (int j = 0; j <= withBlock1.Vertexes - 1; j++) { withBlock1.Weight[j].X = BSReader.ReadSingle(); withBlock1.Weight[j].Y = BSReader.ReadSingle(); withBlock1.Weight[j].Z = BSReader.ReadSingle(); withBlock1.Weight[j].SomeByte = BSReader.ReadByte(); withBlock1.Weight[j].CONN = BSReader.ReadByte(); withBlock1.Weight[j].Null1 = BSReader.ReadUInt16(); } break; } case 5: { withBlock1.UVHead = head; withBlock1.UV = new Position3[withBlock1.Vertexes]; for (int j = 0; j <= withBlock1.Vertexes - 1; j++) { withBlock1.UV[j].X = BSReader.ReadSingle(); withBlock1.UV[j].Y = BSReader.ReadSingle(); withBlock1.UV[j].Z = BSReader.ReadSingle(); } break; } case 6: { withBlock1.ShiteHead = head; withBlock1.Shit = new uint[withBlock1.Vertexes]; for (int j = 0; j <= withBlock1.Vertexes - 1; j++) { withBlock1.Shit[j] = BSReader.ReadUInt32(); } break; } } head = BSReader.ReadUInt32(); } withBlock1.EndSignature1 = head; withBlock1.EndSignature2 = BSReader.ReadUInt32(); withBlock1.leftovers = new byte[] { }; _Groups.Add(withBlock1); } withBlock.Group = _Groups.ToArray(); Array.Resize(ref withBlock.Group[withBlock.Group.Length - 1].leftovers, (int)(withBlock.BlockSize + offset - ByteStream.Position)); withBlock.Group[withBlock.Group.Length - 1].leftovers = BSReader.ReadBytes((int)(withBlock.BlockSize + offset - ByteStream.Position)); SubModel[i] = withBlock; } _Groups.Clear(); }
private static extern int sys_getgrgid (uint uid, out _Group group);
private static extern int sys_getgrnam (string name, out _Group group);
private static int sys_getgrnam(string name, out _Group group) { throw new System.NotImplementedException(); }
public ActionResult CreateGroup(_Group gr) { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true && org.ExpiryDate >= DateTime.Now && org.IsDeleted == false).Select(org => org), "OrganisationID", "OrganisationName"); gr.DateFormatForClientSide = ConfigurationManager.AppSettings["dateformatForCalanderClientSide"].ToString(); if (ModelState.IsValid) // model validation { var checkGroupName = db.Groups.Where(grp => grp.GroupName.TrimEnd().TrimStart().ToLower() == gr.GroupName.TrimEnd().TrimStart().ToLower()).Select(grp => grp).SingleOrDefault(); if (checkGroupName == null) // check the duplicate name for group { var maxuserAllowed = db.Organisations.Where(a => a.OrganisationID == gr.OrganisationID).FirstOrDefault(); if (maxuserAllowed != null && maxuserAllowed.MaxUsers < gr.MaxUsers) { ModelState.AddModelError("maxnoofuser", LMSResourse.Admin.Group.msgErrorGreaterthan + maxuserAllowed.MaxUsers); return(View(gr)); } var temp = ConfigurationManager.AppSettings["dateformatForCalanderServerSide"].ToString(); Group grp = new Group(); grp.Status = gr.Status; grp.GroupName = gr.GroupName; grp.GroupDescription = gr.GroupDescription; grp.GroupManager = gr.GroupManager; grp.EmailAddress = gr.EmailAddress; grp.ContactNo = gr.ContactNo; if (gr.OrganisationID != null && gr.OrganisationID.ToString() != "") { grp.OrganisationID = gr.OrganisationID; grp.MaxUsers = gr.MaxUsers; } grp.CreationDate = DateTime.Now; grp.CreatedById = Convert.ToInt64(Session["UserID"]); grp.IsDeleted = false; db.Groups.Add(grp); db.SaveChanges(); // save th group data in database GroupInfo grInfo = new GroupInfo(); // create group info record grInfo.GroupID = grp.GroupID; grInfo.LanguageId = db.InstanceInfoes.Find(1).DefaultLanguage; grInfo.GroupName = gr.GroupName; grInfo.GroupDescription = gr.GroupDescription; grInfo.GroupManager = gr.GroupManager; grInfo.EmailAddress = gr.EmailAddress; grInfo.ContactNo = gr.ContactNo; grInfo.CreatedById = grp.CreatedById; grInfo.CreationDate = grp.CreationDate; db.GroupInfoes.Add(grInfo); db.SaveChanges(); return(RedirectToAction("Index", "Groups")); } else // return model with error message { ModelState.AddModelError("GroupName", LMSResourse.Admin.Group.errDupGroup); } } var li = ModelState.Values.ToArray(); ModelState item = li[7]; if (item != null && item.Errors.Count > 0) { ModelState.AddModelError("maxnoofuser", LMSResourse.Admin.Group.msgErrorIntegerOnly); } return(View(gr)); }
private static extern int sys_getgrnam_r (string name, out _Group grbuf, out IntPtr grbufp);
public ActionResult EditGroup(_Group Objgrp) { var currentLoginUser = Convert.ToInt64(Session["UserID"].ToString()); if ((Session["UserRoles"].ToString()).Split(',').Select(int.Parse).ToArray().Contains(2)) // group administrator can not edit the group. { var GroupAdminGroups = db.UserGroups.Where(x => x.UserId == currentLoginUser).Select(x => x.GroupID).ToList(); if (!GroupAdminGroups.Contains(Objgrp.GroupID)) { return(RedirectToAction("Index", "Groups")); } } if (Objgrp.OrganisationID != null) // if organisation is not selected { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName", Objgrp.OrganisationID); } else // if organisation selected { ViewBag.OrgList = new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName"); } if (ModelState.IsValid) // model validation { var duplicateTile = db.Groups.Where(grp => grp.GroupName == Objgrp.GroupName && grp.GroupID != Objgrp.GroupID).FirstOrDefault(); if (duplicateTile == null) // check duplicate group name { var dbObjgrp = db.Groups.Find(Objgrp.GroupID); // find the group if (dbObjgrp != null) // if not the return the model with error message. { if (dbObjgrp.OrganisationID != null) { // check is this group is the last group which is assigned to organisation if yes then it can't be updated as this is the last group which is assigned to this organisation. var OrgCount = db.Groups.Where(x => x.OrganisationID == dbObjgrp.OrganisationID && x.IsDeleted == false).Count(); if (OrgCount <= 1 && Objgrp.OrganisationID == null) { ModelState.AddModelError("OrganisationID", "Organisation can be null. as this is the last group assigned to the organisation."); return(View(Objgrp)); } } var isOrgNull = Objgrp.OrganisationID != null ? Objgrp.OrganisationID : 0; var maxuserAllowed = db.Organisations.Where(a => a.OrganisationID == isOrgNull).FirstOrDefault(); if (maxuserAllowed != null && maxuserAllowed.MaxUsers >= Objgrp.MaxUsers) { } else { if (isOrgNull != 0) { ModelState.AddModelError("maxnoofuser", LMSResourse.Admin.Group.msgErrorGreaterthan + (Objgrp.MaxUsers == 0 ? "" : maxuserAllowed == null ? " allowed" : maxuserAllowed.MaxUsers.ToString())); return(View(Objgrp)); } } var membersIngroup = db.Groups.Where(a => a.GroupID == Objgrp.GroupID).FirstOrDefault().UserGroups.Count(); if (dbObjgrp.OrganisationID != null) { if ((maxuserAllowed != null && maxuserAllowed.MaxUsers >= Objgrp.MaxUsers) && membersIngroup <= Objgrp.MaxUsers) { } else { ModelState.AddModelError("maxnoofuser", "No of users can not change. Because there is already " + membersIngroup + " members in this group"); return(View(Objgrp)); } } // update the existing record. dbObjgrp.GroupID = Objgrp.GroupID; dbObjgrp.GroupName = Objgrp.GroupName; dbObjgrp.GroupDescription = Objgrp.GroupDescription; dbObjgrp.OrganisationID = Objgrp.OrganisationID != null ? Objgrp.OrganisationID : null; //dbObjgrp.Organisation = (Objgrp.Organisation != null) ? Objgrp.Organisation : null; dbObjgrp.GroupManager = Objgrp.GroupManager; dbObjgrp.EmailAddress = Objgrp.EmailAddress; dbObjgrp.ContactNo = Objgrp.ContactNo; dbObjgrp.DateLastModified = DateTime.Now; dbObjgrp.LastModifiedByID = Convert.ToInt64(Session["UserID"]); dbObjgrp.Status = Objgrp.Status; if (Objgrp.OrganisationID != null && Objgrp.OrganisationID.ToString() != "") { dbObjgrp.MaxUsers = Objgrp.MaxUsers; } else { dbObjgrp.MaxUsers = 0; } db.SaveChanges(); // save the data of group var LanguageId = db.InstanceInfoes.Find(1).DefaultLanguage; var gInfo = db.GroupInfoes.Where(x => x.GroupID == dbObjgrp.GroupID && x.LanguageId == LanguageId).FirstOrDefault(); if (gInfo != null) // if group info information in not exist then create a new record else update the existing record. { // update group info record. gInfo.GroupID = dbObjgrp.GroupID; gInfo.LanguageId = LanguageId; gInfo.GroupName = dbObjgrp.GroupName; gInfo.GroupDescription = dbObjgrp.GroupDescription; gInfo.GroupManager = dbObjgrp.GroupManager; gInfo.EmailAddress = dbObjgrp.EmailAddress; gInfo.ContactNo = dbObjgrp.ContactNo; gInfo.LastModifiedByID = dbObjgrp.LastModifiedByID; gInfo.DateLastModified = dbObjgrp.DateLastModified; db.SaveChanges(); } else // create new record for groupinfo table { gInfo = new GroupInfo(); gInfo.GroupID = dbObjgrp.GroupID; gInfo.LanguageId = LanguageId; gInfo.GroupName = dbObjgrp.GroupName; gInfo.GroupDescription = dbObjgrp.GroupDescription; gInfo.GroupManager = dbObjgrp.GroupManager; gInfo.EmailAddress = dbObjgrp.EmailAddress; gInfo.ContactNo = dbObjgrp.ContactNo; gInfo.CreatedById = Convert.ToInt64(Session["UserID"]); gInfo.CreationDate = DateTime.Now; db.GroupInfoes.Add(gInfo); db.SaveChanges(); } return(RedirectToAction("Index", "Groups")); } else { return(HttpNotFound()); // if record not fond. } } else // return model with error message. { ModelState.AddModelError("GroupName", LMSResourse.Admin.Group.errDupGroup); } } // if organistion is not selected then return the organisation list. ViewBag.OrgList = (Objgrp.OrganisationID == null) ? new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName") : new SelectList(db.Organisations.Where(org => org.Status == true).OrderBy(org => org.OrganisationName).Select(org => org), "OrganisationID", "OrganisationName", Objgrp.OrganisationID); var li = ModelState.Values.ToArray(); ModelState item = li[8]; if (item != null && item.Errors.Count > 0) { ModelState.AddModelError("maxnoofuser", LMSResourse.Admin.Group.msgErrorIntegerOnly); } return(View(Objgrp)); }