/// <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); }
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(); } }