public ActionResult Index() { return(ActionResultHelper.TryCatchWithLogger(() => { PreservationVerifyIndexModel model = new PreservationVerifyIndexModel(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { DocumentCondition conditions = new DocumentCondition(); List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>(); conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>(); conditions.DocumentAttributeConditions.Add(new DocumentCondition() { Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); sortConditions.Add(new DocumentSortCondition { Name = "Name", Dir = "ASC" }); model.archives = ArchiveService.GetArchives(0, int.MaxValue, conditions, sortConditions, out int total, customerCompany.CompanyId).ToList(); } else { model.archives = UserArchive.GetUserArchivesPaged(User.Identity.Name, 0, int.MaxValue, out int total, customerCompany.CompanyId); } return View(model); }, _loggerService)); }
public async Task <UserArchive> CreateUserArchive(UserArchive userArchive) { await _context.UserArchives.AddAsync(userArchive); await _context.SaveChangesAsync(); return(userArchive); }
public async Task <IActionResult> CreateUserArchive(UserArchiveForAddDto userArchiveForAddDto) { var userArchiveToCreate = new UserArchive { // Updated = DateTime.Today, Age = userArchiveForAddDto.Age, Height = userArchiveForAddDto.Height, Weight = userArchiveForAddDto.Weight, PAL = userArchiveForAddDto.PAL, BMI = userArchiveForAddDto.BMI, BMIlevel = userArchiveForAddDto.BMIlevel, BMR = userArchiveForAddDto.BMR, TEE = userArchiveForAddDto.TEE, UserId = userArchiveForAddDto.UserId }; var createdUserArchive = await _repo.CreateUserArchive(userArchiveToCreate); return(StatusCode(201)); }
public ActionResult GridArchives([DataSourceRequest] DataSourceRequest request) { var result = new DataSourceResult(); try { int total = 0; int skip = request.Page - 1; int take = request.PageSize; skip = (skip < 1) ? 0 : skip * take; CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { DocumentCondition conditions = new DocumentCondition(); List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>(); conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>(); conditions.DocumentAttributeConditions.Add(new DocumentCondition() { Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); if (request.Filters != null) { foreach (var item in request.Filters) { //conditions.DocumentAttributeConditions.Add(new DocumentCondition { Name = item., Value = item.Value, Operator = Library.Common.Enums.DocumentConditionFilterOperator.Contains, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); } } if (request.Sorts != null) { foreach (var item in request.Sorts) { sortConditions.Add(new DocumentSortCondition { Name = item.Member, Dir = item.SortDirection }); } } else { sortConditions.Add(new DocumentSortCondition { Name = "Name", Dir = "ASC" }); } result.Data = ArchiveService.GetArchives(skip, take, conditions, sortConditions, out total, customerCompany.CompanyId).ToList(); } else { result.Data = UserArchive.GetUserArchivesPaged(User.Identity.Name, skip, take, out total, customerCompany.CompanyId); } result.Total = total; } catch (Exception ex) { result.Errors = ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult GridPreservationVerify([DataSourceRequest] DataSourceRequest request) { var result = new DataSourceResult(); try { int total = 0; int skip = (request.Page - 1) * request.PageSize; int take = request.PageSize; if (skip < 0) { skip = 0; } var service = new PreservationService(); const int ARCHIVES_TAKE = 5; int archiveSkip = 0, totalArchives; List <DocumentArchive> archivi = null; CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { DocumentCondition conditions = new DocumentCondition(); List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>(); conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>(); conditions.DocumentAttributeConditions.Add(new DocumentCondition() { Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); if (request.Filters != null) { foreach (var item in request.Filters) { //conditions.DocumentAttributeConditions.Add(new DocumentCondition { Name = item., Value = item.Value, Operator = Library.Common.Enums.DocumentConditionFilterOperator.Contains, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); } } if (request.Sorts != null) { foreach (var item in request.Sorts) { sortConditions.Add(new DocumentSortCondition { Name = item.Member, Dir = item.SortDirection }); } } else { sortConditions.Add(new DocumentSortCondition { Name = "Name", Dir = "ASC" }); } archivi = ArchiveService.GetArchives(skip, take, conditions, sortConditions, out total, customerCompany.CompanyId).ToList(); } else { archivi = UserArchive.GetUserArchivesPaged(User.Identity.Name, archiveSkip, ARCHIVES_TAKE, out totalArchives, customerCompany.CompanyId); if (archivi.Count < totalArchives) { for (archiveSkip += ARCHIVES_TAKE; archiveSkip < totalArchives; archiveSkip += ARCHIVES_TAKE) { archivi.AddRange(UserArchive.GetUserArchivesPaged(User.Identity.Name, archiveSkip, ARCHIVES_TAKE, out totalArchives, customerCompany.CompanyId)); } } if (archivi.Any()) { result.Data = service.GetPreservationVerify(archivi.Select(x => x.IdArchive).ToArray <Guid>(), skip, take, out total, null); } else { result.Data = archivi; } } result.Total = total; } catch (Exception ex) { result.Errors = ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }