/// <summary> /// Se agrega un nuevo registro a los roles /// </summary> /// <param name="dbModel">Representa un objecto con la informacion del rol</param> /// <returns>Entero con la respueta: 1, OK. 2, KO. 3, Ya existe</returns> public int RecordCreation(RoleDbModel dbModel) { using (ConstructoraUdcDBEntities db = new ConstructoraUdcDBEntities()) { try { // Verifica si existe un rol con nombre que se quiere crear if (db.SEC_Role.Where(x => x.name.ToUpper().Equals(dbModel.Name.ToUpper())).Count() > 0) { return(3); } RoleModelMapper mapper = new RoleModelMapper(); SEC_Role record = mapper.MapperT2T1(dbModel); db.SEC_Role.Add(record); db.SaveChanges(); return(1); } catch { return(2); } } }
public int RecordCreation(RoleDbModel dbModel) { ///<summary> ///Se agrega un registro a roles ///</summary> ///<param name = "DbModel">Representa un objeto con la informacion Rol ///</param> ///<returns>Entero con la Respuesta: 1. Ok , 2. Ko, 3, Ya existe</returns> using (ConstructoraUdcDBEntities db = new ConstructoraUdcDBEntities()) { try { if (db.SEC_Role.Where(x => x.name.ToUpper().Equals(dbModel.Name.ToUpper())).Count() > 0) { return(3); } RoleModelMapper mapper = new RoleModelMapper(); SEC_Role record = mapper.MapperT2T1(dbModel); db.SEC_Role.Add(record); db.SaveChanges(); return(1); } catch (Exception e) { return(2); } } }
public ValidationResult EditRole(SEC_Role modeRole, string action, out string status) { _roleSetupDataService.AddRole(modeRole, action, out status); if (status.Length > 0) { return(new ValidationResult(status, _localizationService.GetResource(status))); } return(ValidationResult.Success); }
public async Task <dynamic> EditRole(SEC_Role modelRole) { if (ModelState.IsValid) { action = "edit"; respStatus = await Task.Run(() => _roleSetupService.EditRole(modelRole, action, out outStatus)); return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } else { respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); } return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); }
public async Task <dynamic> AddRole(SEC_Role modelRole) { if (ModelState.IsValid) { action = "add"; respStatus = await Task.Run(() => _roleSetupService.AddRole(modelRole, action, out outStatus)); return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); } return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); }
public string AddRole(SEC_Role modelRole, string action, out string errorNumber) { errorNumber = String.Empty; try { DatabaseProviderFactory factory = new DatabaseProviderFactory(); SqlDatabase db = factory.CreateDefault() as SqlDatabase; using (DbCommand dbCommandWrapper = db.GetStoredProcCommand("SetRole")) { db.AddInParameter(dbCommandWrapper, "@RoleID", SqlDbType.NVarChar, modelRole.RoleID); db.AddInParameter(dbCommandWrapper, "@OwnerID", SqlDbType.NVarChar, modelRole.Owner.OwnerID); db.AddInParameter(dbCommandWrapper, "@RoleTitle", SqlDbType.NVarChar, modelRole.RoleTitle); db.AddInParameter(dbCommandWrapper, "@RoleDescription", SqlDbType.NVarChar, modelRole.RoleDescription); db.AddInParameter(dbCommandWrapper, "@RoleType ", SqlDbType.NVarChar, modelRole.RoleType); db.AddInParameter(dbCommandWrapper, "@UserLevel", SqlDbType.NVarChar, modelRole.UserLevel); db.AddInParameter(dbCommandWrapper, "@SetBy ", SqlDbType.NVarChar, modelRole.SetBy); db.AddInParameter(dbCommandWrapper, "@ModifiedBy", SqlDbType.NVarChar, modelRole.ModifiedBy); db.AddInParameter(dbCommandWrapper, "@Status", SqlDbType.Int, modelRole.Status); db.AddInParameter(dbCommandWrapper, "@Action", SqlDbType.VarChar, action); db.AddOutParameter(dbCommandWrapper, spStatusParam, SqlDbType.VarChar, 10); db.ExecuteNonQuery(dbCommandWrapper); if (!db.GetParameterValue(dbCommandWrapper, spStatusParam).IsNullOrZero()) { errorNumber = db.GetParameterValue(dbCommandWrapper, spStatusParam).PrefixErrorCode(); } } } catch (Exception ex) { errorNumber = "E404"; } return(errorNumber); }