/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoGroup = new Group_ADO(); //Check if the Group is used in a related entity. If so, we can't proceed with the delete request if (adoGroup.IsInUse(Ado, DTO.GrpCode)) { //The Group is in use by at least one related entity, we cannot proceed with the delete request Log.Instance.Debug("Delete request for Group Code: " + DTO.GrpCode + " refused because it is in use by at least one related entity"); Response.error = Label.Get("error.delete"); return(false); } //attempting to delete. The number of entities deleted are passed to the entitiesDeleted variable (this is 1 for a successful delete) int nDeleted = adoGroup.Delete(Ado, DTO, SamAccountName); if (nDeleted == 0) { Log.Instance.Debug("Can't delete Group"); Response.error = Label.Get("error.delete"); return(false); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //Validation of parameters and user have been successful. We may now proceed to read from the database var adoGroup = new Group_ADO(); //First we must check if the Group exists already (we can't have duplicates) if (adoGroup.Exists(Ado, DTO.GrpCode)) { //This Group exists already, we can't proceed Log.Instance.Debug("Group exists already - create request refused"); Response.error = Label.Get("error.duplicate"); return(false); } //Create the Group - and retrieve the newly created Id int newId = adoGroup.Create(Ado, DTO, SamAccountName); if (newId == 0) { Log.Instance.Debug("Can't create Group"); Response.error = Label.Get("error.create"); return(false); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoGroup = new Group_ADO(); if (!DTO.GrpCodeNew.Equals(DTO.GrpCodeOld)) { //We are changing the Group Code but first we must check if the new Group Code exists already (we can't have duplicates) if (adoGroup.Exists(Ado, DTO.GrpCodeNew)) { //This Group exists already, we can't proceed Log.Instance.Debug("Group exists already - create request refused"); Response.error = Label.Get("error.duplicate"); return(false); } } //Update the Group - and retrieve the number of updated rows int nUpdated = adoGroup.Update(Ado, DTO, SamAccountName); if (nUpdated == 0) { Log.Instance.Debug("Can't update the Group"); Response.error = Label.Get("error.update"); return(false); } FlushAssociatedMatrixes(Ado, DTO); Log.Instance.Debug("Group updated: " + JsonConvert.SerializeObject(DTO)); Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //Validation of parameters and user have been successful. We may now proceed to read from the database var adoGroup = new Group_ADO(); ADO_readerOutput result; //If we're not reading a specific user, then we assume the read is for the userPrincipal if (string.IsNullOrEmpty(DTO.CcnUsername)) { DTO.CcnUsername = SamAccountName; } //If this is a Power user or admin, we just return everything if (Account_BSO_Read.IsPowerUser(Ado, DTO.CcnUsername) || Account_BSO_Read.IsAdministrator(Ado, DTO.CcnUsername)) { DTO.GrpCode = null; result = adoGroup.Read(Ado, DTO); } //otherwise we get only the groups for the specified user else { result = adoGroup.ReadAccess(Ado, DTO.CcnUsername); } if (!result.hasData) { return(false); } Response.data = result.data; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //Validation of parameters and user have been successful. We may now proceed to read from the database var adoGroup = new Group_ADO(); //Groups are returned as an ADO result ADO_readerOutput result = adoGroup.Read(Ado, DTO); if (!result.hasData) { return(false); } Response.data = result.data; return(true); }
internal static bool CheckGroupExists(dynamic dto) { ADO ado = new ADO("defaultConnection"); try { if (dto.GrpCode == null) { return(false); } Group_ADO gAdo = new Group_ADO(); return(gAdo.Exists(ado, dto.GrpCode)); } catch (Exception ex) { throw ex; } finally { ado.Dispose(); } }