public async Task <JsonResult> STInsert() { var id = Guid.Parse(Request.Form["id"]); var name = Request.Form["name"]; var desc = Request.Form["desc"]; var oid = Guid.Parse(Request.Form["oid"]); var aid = Guid.Parse(Request.Form["aid"]); var dtid = Guid.Parse(Request.Form["dtid"]); var catID = Guid.Parse(Request.Form["cid"]); var uid = Guid.Parse(Request.Form["uid"]); var sadmin = Guid.Parse("3c35cccc-d48d-4721-9283-d58faeac6cc1"); try { if (!UserAccessLevelService.HasAccess(uid, sadmin)) { return(Failed(MessageUtilityService.ContactAdmin("Content"))); } if (StatusTypesReferencesService.Insert(id, name, desc, oid, aid, dtid, catID)) { return(Success(id.ToString())); } DateTimeStorageService.RemoveAdmin(dtid); return(Failed(MessageUtilityService.FailedInsert(""))); } catch { DateTimeStorageService.RemoveAdmin(dtid); return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> UAuthenticate() { try { var email = Request.Form["email"]; var pass = Request.Form["pass"]; var aid = Guid.Parse(Request.Form["aid"]); var userInfo = UsersService.GetByEmailAddress(email); if (userInfo == null) { return(Failed(MessageUtilityService.AuthenticationFailed())); } if (userInfo.isAllowAccess) { if (UsersService.ComparePassword(userInfo.Password, pass)) { var vm = UsersService.SetSubData(userInfo, aid); if (UserAccessLevelService.HasAccess(userInfo.ID, superAdmin)) { vm.Password = pass; } return(Success(vm)); } } return(Failed(MessageUtilityService.AuthenticationFailed())); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> UALRemove() { try { var id = Guid.Parse(Request.Form["id"]); var uid = Guid.Parse(Request.Form["uid"]); var aid = Guid.Parse(Request.Form["aid"]); if (UserAccessLevelService.Remove(id, uid, aid)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedRemove(""))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> UALInsert() { try { var id = Guid.Parse(Request.Form["id"]); var uid = Guid.Parse(Request.Form["uid"]); var alid = Guid.Parse(Request.Form["alid"]); var aid = Guid.Parse(Request.Form["aid"]); var dtid = Guid.Parse(Request.Form["dtid"]); var ia = Boolean.Parse(Request.Form["ia"]); if (UserAccessLevelService.Insert(id, uid, alid, aid, dtid, ia)) { return(Success(id.ToString())); } return(Failed(MessageUtilityService.FailedInsert(""))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> UALGetByUID() { try { var email = Request.Form["email"]; var pass = Request.Form["pass"]; var uid = Guid.Parse(Request.Form["uid"]); if (UsersService.HasUserAccess(email, pass, superAdmin)) { var data = UserAccessLevelService.GetByUID(uid, false); return(Success(UserAccessLevelService.SetSubDatasAdmin(data))); } return(Failed(MessageUtilityService.ContactAdmin("Content"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
private static bool InsertUserAccessLevel(Guid aid, Guid uid) { try { var dtid = Guid.NewGuid(); var ualID = Guid.NewGuid(); DateTimeStorageService.Insert(dtid, ualID, aid, DateTime.Now, DateTime.Now, Guid.Parse("c4926f90-2be8-4c62-94ed-5399be276f11")); //check if application exist and user exist if (ApplicationInformationService.IsApplicationExist(aid) && UsersService.IsUserExist(uid)) { //insert new user access level for this user var ual = Guid.Parse("a2e2d83d-dd8d-4a66-bacf-94ad90344ca7"); UserAccessLevelService.Insert(ualID, uid, ual, aid, dtid, false); } return(true); } catch { return(false); } }
public async Task <JsonResult> STGet() { //user id to determine accessLevel var uid = Guid.Parse(Request.Form["id"]); var sadmin = Guid.Parse("3c35cccc-d48d-4721-9283-d58faeac6cc1"); try { //check if uid has super admin access if (UserAccessLevelService.HasAccess(uid, sadmin)) { var data = StatusTypesReferencesService.GetAll(); return(Success(StatusTypesReferencesService.SetSubDatasAdmin(data))); } return(Failed(MessageUtilityService.ContactAdmin("Error"))); } catch { return(Failed(MessageUtilityService.ServerError())); } }
public async Task <JsonResult> UALGetByList() { try { var id = Guid.Parse(Request.Form["id"]); var aid = Guid.Parse(Request.Form["aid"]); var data = UserAccessLevelService.GetByUIDAID(id, aid, false); if (data.Count <= 0) { if (InsertUserAccessLevel(aid, id)) { data = UserAccessLevelService.GetByUIDAID(id, aid, false); } } var vms = UserAccessLevelService.SetSubDatas(data, aid); return(Success(vms)); } catch { return(Failed(MessageUtilityService.ServerError())); } }