public ActionResult Submit(GroupsViewModel groups) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); try { if (ModelState.IsValid) { if (groups.Id <= 0) { groups.TenantId = tenant.TenantId; groups.DateCreated = DateTime.UtcNow; groups.DateUpdated = DateTime.UtcNow; groups.CreatedBy = user.UserId; groups.UpdatedBy = user.UserId; //insert groups.Id = _groupsServices.Insert(Mapper.Map <Groups>(groups), CurrentUserId); ViewBag.Message = $"Successfully Added on {DateTime.Now}."; } else { //update Groups newGroup = _groupsServices.GetByGroupsId(groups.Id); //groups.TenantId = Tenant.TenantId; newGroup.GroupName = groups.GroupName; newGroup.DateUpdated = DateTime.UtcNow; newGroup.UpdatedBy = user.UserId; _groupsServices.Update(Mapper.Map <Groups>(newGroup), CurrentUserId); ViewBag.Message = $"Successfully Updated on {DateTime.Now}."; } return(RedirectToAction("Index", new { message = ViewBag.Message })); } else //ModelState.IsValid is not valid { return(View("_CreateEdit", Mapper.Map(_groupsServices.GetByGroupsId(groups.Id), new GroupsViewModel()))); } } catch (Exception e) { //log exception var err = e.Message; return(View("_ErrorResult")); } }
public void Put([FromBody] SG.Group group) { groupServices.Update(group); }