public override ActionResult AppDosage(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new AppDosageRepository().GetStageByAppDosageId(id.Value); if (model == null) { return(HttpNotFound()); } FillDosageControl(model); model.EXP_DrugDosage.EXP_DrugDeclaration.ExpDicPrimaryOtds = new ReadOnlyDictionaryRepository().GetExpDicPrimaryOTDs().Where(e => e.ParentId == null).ToList(); model.ExpertisePharmacologicalFinalDoc = model.EXP_ExpertisePharmacologicalFinalDoc.FirstOrDefault(); if (model.ExpertisePharmacologicalFinalDoc == null) { model.ExpertisePharmacologicalFinalDoc = new EXP_ExpertisePharmacologicalFinalDoc(); model.ExpertisePharmacologicalFinalDoc.EXP_ExpertiseStageDosage = model; } var repository = new ReadOnlyDictionaryRepository(); ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repository.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu", model.ResultId); var stageName = ExpStageNameHelper.GetName(GetStage()); ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber); //todo во всех контроллерах так, позже можно замутить через наследование return(PartialView("~/Views/DrugDeclaration/AppDosage.cshtml", model)); }
public override ActionResult AppDosage(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var dosageRepository = new AppDosageRepository(); var model = dosageRepository.GetStageByAppDosageId(id.Value); if (model == null) { return(HttpNotFound()); } FillDosageControl(model); var safetyReportDosageStage = dosageRepository.GetStageDosage(model.DosageId, CodeConstManager.STAGE_SAFETYREPORT); model.ExpertiseSafetyreportFinalDoc = safetyReportDosageStage != null?safetyReportDosageStage.EXP_ExpertiseSafetyreportFinalDoc.FirstOrDefault() : null; model.EXP_DrugDosage.EXP_DrugDeclaration.ExpDicPrimaryOtds = new ReadOnlyDictionaryRepository().GetExpDicPrimaryOTDs().Where(e => e.ParentId == null).ToList(); var repository = new ReadOnlyDictionaryRepository(); ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repository.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu", model.ResultId); var stageName = ExpStageNameHelper.GetName(GetStage()); ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber); return(PartialView("~/Views/DrugDeclaration/AppDosage.cshtml", model)); }
public ActionResult PermissionRoleValueList() { ActionLogger.WriteInt("Получение списка ролей доступа"); var data = db.PermissionRoles.Select(o => new { Id = o.Id, Name = o.Name }).OrderBy(x => x.Name).ToList(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult PermissionRoleDestroy([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary) { if (dictionary != null) { var roleId = dictionary.Id; var dbRole = db.PermissionRoles.SingleOrDefault(x => x.Id == roleId); if (dbRole == null) { ModelState.AddModelError("Message", Convert.ToString("Роль не найдена")); return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); } var dbEmployees = db.EmployeePermissionRoles.Where(x => x.PermissionRoleId == roleId) .Join(db.Employees, x => x.EmployeeId, x => x.Id, (r, e) => e).ToList(); if (dbEmployees.Count > 0) { var empl = dbEmployees[0]; var employeeNames = empl.LastName + " " + empl.FirstName + " " + empl.MiddleName; var otherCount = dbEmployees.Count - 1; if (otherCount > 0) { employeeNames += " и ещё " + otherCount + " сотрудник(ов)"; } ModelState.AddModelError("Message", Convert.ToString("Роль использует " + employeeNames)); return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); } db.PermissionRoles.Remove(dbRole); ActionLogger.WriteInt(db, "Удаление роли прав доступа", "RoleId: " + dbRole.Id + "; Name: " + dbRole.Name); db.SaveChanges(); EmployePermissionHelper.RemoveRolePermissionKeys(dbRole.Id); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult DeletePermissionRole(int roleId) { var dbRole = db.PermissionRoles.SingleOrDefault(x => x.Id == roleId); if (dbRole == null) { return(Json(new { success = false, message = "Роль не найдена" })); } var dbEmployees = db.EmployeePermissionRoles.Where(x => x.PermissionRoleId == roleId) .Join(db.Employees, x => x.EmployeeId, x => x.Id, (r, e) => e).ToList(); if (dbEmployees.Count > 0) { var empl = dbEmployees[0]; var employeeNames = empl.LastName + " " + empl.FirstName + " " + empl.MiddleName; var otherCount = dbEmployees.Count - 1; if (otherCount > 0) { employeeNames += " и ещё " + otherCount + " сотрудник(ов)"; } return(Json(new { success = false, message = "Роль использует " + employeeNames })); } db.PermissionRoles.Remove(dbRole); ActionLogger.WriteInt(db, "Удаление роли прав доступа", "RoleId: " + roleId + "; RoleName" + dbRole.Name); db.SaveChanges(); return(Json(new { success = true, message = "Роль успешно удалена" })); }
public void SetExpertiseStageDosageResult(Guid dosageStageId, int resultId) { var creatorId = UserHelper.GetCurrentEmployee().Id; var dosageStage = AppContext.EXP_ExpertiseStageDosage.First(e => e.Id == dosageStageId); dosageStage.ResultId = resultId; var r = new EXP_ExpertiseStageDosageResult(); r.ResultDate = DateTime.Now; r.ResultId = resultId; r.ResultCreatorId = creatorId; r.StageDosageId = dosageStageId; //todo тут похорошему ещё говнопроверок надо напихать, если заявка на совете, похорошему её нельзя редактировать var lastResultInCommission = AppContext.CommissionDrugDosages.FirstOrDefault(x => x.DrugDosageId == dosageStage.DosageId && x.StageId == dosageStage.StageId && x.ConclusionTypeId == null); if (lastResultInCommission != null) { lastResultInCommission.EXP_ExpertiseStageDosageResult = r; } AppContext.EXP_ExpertiseStageDosageResult.Add(r); var addLogInfo = ""; addLogInfo += "resultId: " + resultId; ActionLogger.WriteInt(AppContext, creatorId, "Заявка №" + dosageStage.EXP_DrugDosage.RegNumber + " выставление результата ", addLogInfo); AppContext.SaveChanges(); }
public ActionResult Design(Guid[] id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = GetAssessmentStage(id[0]); model.OBK_AssessmentDeclaration.Applicant = new EmployeesRepository().GetById(model.OBK_AssessmentDeclaration.EmployeeId); //проверка для кнопки выдать результат var certificateOfComplection = model.OBK_AssessmentDeclaration.OBK_CertificateOfCompletion.FirstOrDefault( e => e.AssessmentDeclarationId == model.DeclarationId); var expDocument = db.OBK_StageExpDocument.FirstOrDefault(o => o.AssessmentDeclarationId == model.OBK_AssessmentDeclaration.Id); if (certificateOfComplection == null) { ViewBag.outputResultAct = false; ViewBag.ZBKTaken = false; } else { ViewBag.outputResultAct = (certificateOfComplection.ActReturnedBack == true && model.OBK_AssessmentDeclaration.ZBKTaken == true); ViewBag.ZBKTaken = (model.OBK_AssessmentDeclaration.ZBKTaken) == true; ViewBag.ActReturnedBack = certificateOfComplection.ActReturnedBack; } FillDeclarationControl(model.OBK_AssessmentDeclaration); var stageName = GetName(model.StageId); ActionLogger.WriteInt(stageName + ": Получение заявления №" + model.OBK_AssessmentDeclaration.Number); // new SafetyAssessmentRepository().AddHistory(model.DeclarationId, OBK_Ref_StageStatus.Completed, model.OBK_AssessmentDeclaration.EmployeeId); return(PartialView(model)); }
public ActionResult ActionLogsRead([DataSourceRequest] DataSourceRequest request) { ActionLogger.WriteInt("Получение списка логов действий"); var data = db.ActionLogsViews; return(Json(data.ToDataSourceResult(request))); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { //if (DateTime.Now > new DateTime(2016, 12, 31)) // return RedirectToAction("LogOn", "Account"); if (ModelState.IsValid) { ncelsEntities ncelsEntities = new ncelsEntities(); Employee employee = ncelsEntities.Employees.Include("Position").FirstOrDefault(o => o.Login == model.UserName); if (employee != null && employee.Position.PositionState == 1) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); Session[UserHelper.ConnectKey] = DateTime.Now.Year.ToString(); SaveUserName(); ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Успех"); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { var user = Membership.GetUser(model.UserName); if (user != null && (user.IsLockedOut || !user.IsApproved)) { ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_); ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Пользователь заблокирован"); } else { ModelState.AddModelError("", Messages.AccountController_LogOn_Имя_пользователя_или_пароль_не_верны_); ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Неверное имя пользователя или пароль"); } } } else { ModelState.AddModelError("", Messages.AccountController_LogOn_Пользователь_заблокирован_); ActionLogger.WriteInt("Вход в систему: " + model.UserName, "Пользователь заблокирован/не найден"); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult ListRegister([DataSourceRequest] DataSourceRequest request, string type, int stage, DeclarationRegistryFilter customFilter = null) { var stageName = ExpStageNameHelper.GetName(stage); ActionLogger.WriteInt(stageName + ": Получение списка заявлений"); var list = new DrugDeclarationRepository().DrugDeclarationRegisterByStatus(type, stage, UserHelper.GetCurrentEmployee().Id, customFilter); var result = list.ToDataSourceResult(request); return(Json(result)); }
public ActionResult SendToNextStage(Guid expStageId, int[] nextStageIds, int?stageResultId = null) { var repository = new ExpertiseStageRepository(); if (repository.HasNotFixedRemarks(expStageId)) { return(Json( new { failed = true, msg = "Невозможно передать на следующий этап так как есть не исправленные замечания" }, JsonRequestBehavior.AllowGet)); } string resultDescription; var expertiseStage = repository.GetById(expStageId); var dec = repository.GetDeclarationByStage(expStageId); if (expertiseStage.EXP_DIC_Stage.Code == CodeConstManager.STAGE_SAFETYREPORT.ToString()) { var rDictionary = new ReadOnlyDictionaryRepository(); EXP_DIC_StageResult stageResult = null; if (stageResultId.HasValue) { stageResult = rDictionary.GetStageResultById(stageResultId.Value); } if (stageResult != null && stageResult.Code == EXP_DIC_StageResult.DoesNotMatchCode) { repository.ToBackStage(dec.Id, expStageId, nextStageIds, out resultDescription); } else { repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription); } } else { repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription); } var from = ExpStageNameHelper.GetName(expertiseStage.StageId); var to = ""; foreach (var nextStageId in nextStageIds) { if (!String.IsNullOrEmpty(to)) { to += ", "; } var stageName = ExpStageNameHelper.GetName(nextStageId); to += stageName; } ActionLogger.WriteInt(" Отправка заявления №" + dec.Number + " на другой этап", "from: " + from + "; to:" + to); return(Json("OK", JsonRequestBehavior.AllowGet)); }
public ActionResult PermissionRoleRead([DataSourceRequest] DataSourceRequest request) { ActionLogger.WriteInt(db, "Получение списка ролей прав доступа"); var data = db.PermissionRoles.OrderByDescending(m => m.Id).Select(o => new { o.Id, o.Name, }); return(Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)); }
public ActionResult EmployeePermissionRoleDestroy([DataSourceRequest] DataSourceRequest request, PermissionRoleModel dictionary, Guid employeeId) { if (dictionary != null) { var dbEmployeeRole = db.EmployeePermissionRoles.Single(x => x.Id == dictionary.EmployeeRoleId); db.EmployeePermissionRoles.Remove(dbEmployeeRole); ActionLogger.WriteInt(db, "Удаление сотруднику роли прав доступа", "RoleId: " + dbEmployeeRole.PermissionRoleId + "; EmployeeId: " + dbEmployeeRole.EmployeeId); db.SaveChanges(); EmployePermissionHelper.ClearEmployeePermission(); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult PermissionRoleCreate([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary) { if (dictionary != null) { db.PermissionRoles.Add(dictionary); ActionLogger.WriteInt(db, "Создание роли прав доступа", "Name: " + dictionary.Name); db.SaveChanges(); EmployePermissionHelper.AddRoleDefaultPermissionKeys(dictionary.Id); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult PermissionRoleUpdate([DataSourceRequest] DataSourceRequest request, PermissionRole dictionary) { if (dictionary != null && ModelState.IsValid) { var dbPermissionRole = db.PermissionRoles.Single(o => o.Id == dictionary.Id); var prevName = dbPermissionRole.Name; dbPermissionRole.Name = dictionary.Name; ActionLogger.WriteInt(db, "Обновление роли прав доступа", "RoleId: " + dbPermissionRole.Id + "; PrevName: " + prevName + "; CurrentName: " + dictionary.Name); db.SaveChanges(); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public override ActionResult AppDosage(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new AppDosageRepository().GetStageByAppDosageId(id.Value); if (model == null) { return(HttpNotFound()); } FillDosageControl(model); var repositoryDic = new ReadOnlyDictionaryRepository(); var repository = new SafetyreportRepository(); model.EXP_DrugDosage.EXP_DrugDeclaration.ExpDicPrimaryOtds = repositoryDic.GetExpDicPrimaryOTDs().Where(e => e.ParentId == null).ToList(); model.ExpertiseSafetyreportFinalDoc = model.EXP_ExpertiseSafetyreportFinalDoc.FirstOrDefault(); if (model.ExpertiseSafetyreportFinalDoc == null) { model.ExpertiseSafetyreportFinalDoc = CreateExpertiseSafetyreportFinalDoc(model); repository.CreateExpertiseSafetyreportFinalDoc(model.ExpertiseSafetyreportFinalDoc); model.ExpertiseSafetyreportFinalDoc.EXP_ExpertiseStageDosage = model; } else { var newExpertiseSafetyreport = CreateExpertiseSafetyreportFinalDoc(model); if (string.IsNullOrEmpty(model.ExpertiseSafetyreportFinalDoc.Conclusion)) { model.ExpertiseSafetyreportFinalDoc.Conclusion = newExpertiseSafetyreport.Conclusion; } if (string.IsNullOrEmpty(model.ExpertiseSafetyreportFinalDoc.ConclusionKz)) { model.ExpertiseSafetyreportFinalDoc.ConclusionKz = newExpertiseSafetyreport.ConclusionKz; } repository.UpdateExpertiseSafetyreportFinalDoc(model.ExpertiseSafetyreportFinalDoc); } ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repositoryDic.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu", model.ResultId); var stageName = ExpStageNameHelper.GetName(GetStage()); ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber); return(PartialView("~/Views/DrugDeclaration/AppDosage.cshtml", model)); }
public ActionResult PermissionRoleKeysUpdate([DataSourceRequest] DataSourceRequest request, PermissionModel permissionModel, int roleId) { if (permissionModel != null && ModelState.IsValid) { var employeePermission = db.PermissionRoleKeys.First(o => o.PermissionRoleId == roleId && o.PermissionKey == permissionModel.KeyType); var prevValue = employeePermission.PermissionValue; employeePermission.PermissionValue = permissionModel.KeyValue; ActionLogger.WriteInt(db, "Обновление разрешений у роли прав доступа", "RoleId: " + roleId + "; Key: " + permissionModel.KeyType + "; PrevValue: " + prevValue + "; CurrentValue: " + permissionModel.KeyValue); db.SaveChanges(); EmployePermissionHelper.ClearEmployeePermission(); } return(Json(new[] { permissionModel }.ToDataSourceResult(request, ModelState))); }
public ActionResult EmployeePermissionRoleRead([DataSourceRequest] DataSourceRequest request, Guid employeeId) { ActionLogger.WriteInt("Получение списка ролей доступа сотрудника", "EmployeeId: " + employeeId); var data = db.EmployeePermissionRoles.Where(o => o.EmployeeId == employeeId) .Join(db.PermissionRoles, x => x.PermissionRoleId, x => x.Id, (ep, r) => new { EmpRole = ep, Role = r }) .Select(o => new PermissionRoleModel { EmployeeRoleId = o.EmpRole.Id, RoleId = o.Role.Id, RoleName = o.Role.Name, }).OrderBy(x => x.RoleName); return(Json(data.ToDataSourceResult(request))); }
public EXP_ExpertiseSafetyreportFinalDoc UpdateFinalDocument(string fieldName, string fieldValue, Guid objectId, Guid userId, bool isFromTranslateController = false) { var appDosage = AppContext.EXP_ExpertiseStageDosage.FirstOrDefault(e => e.Id == objectId); if (appDosage == null) { return(null); } var model = appDosage.EXP_ExpertiseSafetyreportFinalDoc.FirstOrDefault() ?? new EXP_ExpertiseSafetyreportFinalDoc { DosageStageId = appDosage.Id }; var property = model.GetType().GetProperty(fieldName); if (property != null) { var t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; if (string.IsNullOrEmpty(fieldValue)) { fieldValue = null; } var safeValue = fieldValue == null ? null : Convert.ChangeType(fieldValue, t); property.SetValue(model, safeValue, null); } if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); AppContext.EXP_ExpertiseSafetyreportFinalDoc.Add(model); } var addLogInfo = ""; addLogInfo += "field: '" + fieldName + "' value: " + fieldValue; if (isFromTranslateController)//ну сорян, почемуто у перевода своего репозитория нету { ActionLogger.WriteInt(AppContext, "Заявка №" + appDosage.EXP_DrugDosage.RegNumber + " изменения результатов: Перевод", addLogInfo); } else { ActionLogger.WriteInt(AppContext, "Заявка №" + appDosage.EXP_DrugDosage.RegNumber + " изменения результатов: ЗОБ", addLogInfo); } AppContext.SaveChanges(); return(model); }
public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { Employee employee = UserHelper.GetCurrentEmployee(); if (employee != null) { MembershipUser user = Membership.GetUser(employee.Login); if (user != null) { user.ChangePassword(model.OldPassword, model.NewPassword); ActionLogger.WriteInt("Сменил себе пароль"); return(Content(bool.TrueString)); } } } ActionLogger.WriteInt("Пытался сменить себе пароль"); return(Content(bool.FalseString)); }
public bool UpdateOtd(Guid stageId, int noteId, bool isChecked, Guid id) { var repository = new ReadOnlyDictionaryRepository().GetExpDicPrimaryOTDs(); var model = GetExpertiseStageById(stageId); if (model == null) { return(false); } var dic = repository.FirstOrDefault(e => e.Id == noteId); if (model.OtdIds == null) { model.OtdIds = ""; } var otdIds = model.OtdIds.Split(',').ToList(); var prevOtdIds = new List <string>(otdIds); GetOtdChildren(otdIds, dic, isChecked); GetOtdParent(otdIds, dic, isChecked); var uncheckedOtIds = prevOtdIds.Except(otdIds).ToList(); var checkedOtIds = otdIds.Except(prevOtdIds).ToList(); var addLogInfo = ""; if (uncheckedOtIds.Count > 0) { var uncheckedOtIdsStr = String.Join(",", uncheckedOtIds); addLogInfo += "снята галочка с пунктов: " + uncheckedOtIdsStr; } if (checkedOtIds.Count > 0) { var checkedOtIdsStr = String.Join(",", checkedOtIds); addLogInfo += "поставлена галочка в пунктах: " + checkedOtIdsStr; } var stageName = ExpStageNameHelper.GetName(model.StageId); ActionLogger.WriteInt(AppContext, stageName + ": Заявление №" + model.EXP_DrugDeclaration.Number + ": изменения значений экспертизы(галочки)", addLogInfo); model.OtdIds = string.Join(",", otdIds); AppContext.SaveChanges(); return(true); }
public ActionResult Design(Guid[] id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = GetAssessmentStage(id[0]); model.OBK_AssessmentDeclaration.Applicant = new EmployeesRepository().GetById(model.OBK_AssessmentDeclaration.EmployeeId); //ViewBag.CanRefuseExpertise = // model.StageId == CodeConstManager.STAGE_PRIMARY /*&& model.EXP_DIC_StageStatus.Code != EXP_DIC_StageStatus.Completed*/ && // model.OBK_AssessmentDeclaration.StatusId != CodeConstManager.STATUS_EXP_ON_REFUSING_ID // && model.OBK_AssessmentDeclaration.StatusId != CodeConstManager.STATUS_EXP_REFUSED_ID; FillDeclarationControl(model.OBK_AssessmentDeclaration); var stageName = GetName(model.StageId); ActionLogger.WriteInt(stageName + ": Получение заявления №" + model.OBK_AssessmentDeclaration.Number); return(PartialView(model)); }
public ActionResult EmployeePermissionRoleUpdate([DataSourceRequest] DataSourceRequest request, PermissionRoleModel dictionary, Guid employeeId) { if (dictionary != null && ModelState.IsValid) { var dbEmployeeRole = db.EmployeePermissionRoles.SingleOrDefault(x => x.PermissionRoleId == dictionary.RoleId && x.EmployeeId == employeeId && x.Id != dictionary.EmployeeRoleId); if (dbEmployeeRole != null) { ModelState.AddModelError("Message", Convert.ToString("Роль уже присвоена")); return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); } dbEmployeeRole = db.EmployeePermissionRoles.Single(x => x.Id == dictionary.EmployeeRoleId); var prevRoleId = dbEmployeeRole.PermissionRoleId; dbEmployeeRole.PermissionRoleId = dictionary.RoleId; ActionLogger.WriteInt(db, "Обновление сотруднику роли прав доступа", "PrevRoleId: " + prevRoleId + "; CurrentRoleId: " + dictionary.RoleId); db.SaveChanges(); EmployePermissionHelper.ClearEmployeePermission(); } return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult PermissionRoleKeysRead([DataSourceRequest] DataSourceRequest request, int roleId) { ActionLogger.WriteInt("Получение списка разрешений роли прав доступа", "RoleId: " + roleId); var data = db.PermissionRoleKeys.Where(o => o.PermissionRoleId == roleId) .Join(db.PermissionKeys, x => x.PermissionKey, x => x.Key, (r, k) => new { RoleKeys = r, Key = k }) .ToList().Select(o => new PermissionModel() { Id = o.RoleKeys.Id, GroupName = o.Key.GroupName, KeyDescription = EmployePermissionHelper.GeKeys().First(x => x.Key == o.RoleKeys.PermissionKey).KeyDescription, KeyName = EmployePermissionHelper.GeKeys().First(x => x.Key == o.RoleKeys.PermissionKey).KeyName, KeyType = o.RoleKeys.PermissionKey, KeyValue = o.RoleKeys.PermissionValue, KeyPermission = EmployePermissionHelper.GeKeysValue() .Where(x => x.PermissionKey == o.RoleKeys.PermissionKey) .First(y => y.Value == o.RoleKeys.PermissionValue) .Name }); return(Json(data.ToDataSourceResult(request))); }
public EXP_ExpertisePharmacologicalFinalDoc UpdateFinalDocument(string fieldName, string fieldValue, Guid objectId, Guid userId) { var appDosage = AppContext.EXP_ExpertiseStageDosage.FirstOrDefault(e => e.Id == objectId); if (appDosage == null) { return(null); } var model = appDosage.EXP_ExpertisePharmacologicalFinalDoc.FirstOrDefault() ?? new EXP_ExpertisePharmacologicalFinalDoc { DosageStageId = appDosage.Id }; var property = model.GetType().GetProperty(fieldName); if (property != null) { var t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType; if (string.IsNullOrEmpty(fieldValue)) { fieldValue = null; } var safeValue = fieldValue == null ? null : Convert.ChangeType(fieldValue, t); property.SetValue(model, safeValue, null); } if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); AppContext.EXP_ExpertisePharmacologicalFinalDoc.Add(model); } var addLogInfo = ""; addLogInfo += "field: '" + fieldName + "' value: " + fieldValue; ActionLogger.WriteInt(AppContext, "Заявка №" + appDosage.EXP_DrugDosage.RegNumber + " изменения результатов: ФМК", addLogInfo); AppContext.SaveChanges(); return(model); }
public override ActionResult AppDosage(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new AppDosageRepository().GetStageByAppDosageId(id.Value); if (model == null) { return(HttpNotFound()); } FillDosageControl(model); model.ExpDrugAnaliseIndicators = new List <EXP_DrugAnaliseIndicator>(); var list = model.EXP_DrugAnaliseIndicator.OrderBy(e => e.PositionNumber); var repository = new ReadOnlyDictionaryRepository(); var remarkTypes = repository.GetDicAnalyseIndicators().ToArray(); ViewData["AnalyseIndicatorList" + model.Id] = new SelectList(remarkTypes, "Id", "NameRu", null); var booleans = repository.GetBooleanList(); ViewData["Booleans" + model.Id] = new SelectList(booleans, "IsSign", "NameRu", null); foreach (var expDrugAnaliseIndicator in list) { // ViewData["AnalyseIndicatorList"+ expDrugAnaliseIndicator.Id] = new SelectList(remarkTypes, "Id", "NameRu", expDrugAnaliseIndicator.AnalyseIndicator); model.ExpDrugAnaliseIndicators.Add(expDrugAnaliseIndicator); } ViewData["FinalyDocResultList" + model.EXP_DrugDosage.DrugDeclarationId] = new SelectList(repository.GetStageResultsByStage(model.EXP_ExpertiseStage.StageId), "Id", "NameRu", model.ResultId); var stageName = ExpStageNameHelper.GetName(GetStage()); ActionLogger.WriteInt(stageName + ": Получение заявки №" + model.EXP_DrugDosage.RegNumber); return(PartialView("~/Views/DrugAnalitic/AppDosage.cshtml", model)); }