public ServiceResult <List <ObjFinance> > GetList(int rootId, RootTypes rootType) { try { var finances = new List <Finance>(); switch (rootType) { case RootTypes.User: finances = _financeRepository.GetListByUserId(rootId); break; case RootTypes.Client: finances = _financeRepository.GetListByClientId(rootId); break; case RootTypes.Project: finances = _financeRepository.GetListByProjectId(rootId); break; case RootTypes.Finance: finances = _financeRepository.GetList(); break; } var result = finances.Select(x => Map(x)).ToList(); return(ServiceResult <List <ObjFinance> > .SuccessResult(result)); } catch (Exception ex) { return(ServiceResult <List <ObjFinance> > .ErrorResult("Ошибка при загрузке данных")); } }
public List <Participant> Get(int rootId, RootTypes rootType) { return(Queryable <Participant>() .Where(p => p.RootId == rootId && p.RootType == rootType) .Include(x => x.User) .ToList()); }
public List <Status> Get(RootTypes rootType) { var result = Queryable() .Where(status => status.rootType == rootType) .ToList(); return(result); }
public IActionResult New(int rootId, RootTypes rootType, IFormFile file) { string email = HttpContext.User.Identity.Name; var createdId = _userService.GetUserByEmail(HttpContext.User.Identity.Name).Id; var result = _fileDataService.UploadFile(rootId, rootType, file, createdId); return(Json(result)); }
public List <Project> GetList(int rootId, RootTypes rootType) { return(Queryable() .Include(x => x.Status) .Include(x => x.ProjectType) .Where(x => x.RootId == rootId && x.RootType == rootType) .ToList()); }
public Participant Get(int userId, int rootID, RootTypes rootType) { var result = Queryable() .FirstOrDefault(x => x.UserId == userId && x.RootId == rootID && x.RootType == rootType); return(result); }
public List <ObjStatus> GetStatusesByRootType(RootTypes rootType) { var statuses = _statusRepository.Get(rootType); return(statuses .Select(x => Map(x)) .OrderBy(x => x.Position) .ToList()); }
public IActionResult DeleteProject(int id, int rootId, RootTypes rootType) { var result = _projectService.Delete(id); if (result.Success) { return(Json(_projectService.GetProjectList(rootId, rootType))); } return(Json(result)); }
public IActionResult DeleteTask(int id, int rootId, RootTypes rootType) { var result = _taskService.Delete(id); if (result.Success) { return(Json(_taskService.GetTaskList(rootId, rootType))); } return(Json(result)); }
public IActionResult DeleteFinance(int id, int rootId, RootTypes rootType) { var result = _financeService.Delete(id); if (result.Success) { return(RedirectToAction("GetFinancesList", new { rootId, rootType })); } return(Json(result)); }
public IActionResult DeleteFile(int id, int rootId, RootTypes rootType) { var result = _fileDataService.Delete(id); if (result.Success) { return(Json(_fileDataService.GetFiles(rootId, rootType))); } return(Json(result)); }
public string GetRootUrl(RootTypes rootType, int rootId) { string result = string.Empty; switch (rootType) { case RootTypes.Client: result = "/Clients/Details/" + rootId; break; } return(result); }
public bool TryGetOperationType( ObjectTypeDefinitionNode rootType, out OperationType operationType) { if (RootTypes.ContainsValue(rootType)) { operationType = RootTypes.First(t => t.Value == rootType).Key; return(true); } operationType = default; return(false); }
public IActionResult DeleteEntity(int Id, RootTypes rootType) { var result = _deleteEntityService.Delete(Id, rootType); if (result.Success) { return(RedirectToActionOk("Index", result.Result, "Объект удален")); } else { return(RedirectToActionError("Index", "Home", result.ErrorMessage)); } }
public string GetRootName(RootTypes rootType, int rootId) { string result = string.Empty; switch (rootType) { case RootTypes.Client: var client = _clientRepository.Get(rootId); result = client.CompanyName; break; } return(result); }
public ObjParticipantList GetList(int rootId, RootTypes rootType) { ObjParticipantList result = new ObjParticipantList(); var listParticipants = _participantRepository.Get(rootId, rootType); result.list = new List <ObjParticipant>(); foreach (var participant in listParticipants) { result.list.Add(Map(participant)); } return(result); }
public ObjFileDataList GetFiles(int rootId, RootTypes rootType) { ObjFileDataList dataList = new ObjFileDataList(); dataList.Files = new List <ObjFileData>(); var files = _fileDataRepository.GetFiles(rootId, rootType); foreach (var file in files) { dataList.Files.Add(Map(file)); } return(dataList); }
public bool IsRootType(ITypeDefinitionNode typeDefinition) { if (typeDefinition == null) { throw new ArgumentNullException(nameof(typeDefinition)); } if (typeDefinition is ObjectTypeDefinitionNode ot) { return(RootTypes.ContainsValue(ot)); } return(false); }
public ObjContactList GetListContacts(int RootId, RootTypes rootType) { ObjContactList result = new ObjContactList(); var listContact = _contactRepository.GetByRootIdAndType(RootId, rootType); listContact = listContact.OrderBy(c => c.Id); result.Contacts = new List <ObjContact>(); foreach (var contact in listContact) { result.Contacts.Add(Map(contact)); } return(result); }
public ObjCommentList GetListComments(int rootID, RootTypes rootType, int lastId = 0) { ObjCommentList result = new ObjCommentList(); var listComment = _commentRepository.GetByRootIDAndType(rootID, rootType); if (lastId != 0) { listComment.Where(c => c.Id == lastId); } listComment = listComment.OrderBy(c => c.Id); result.items = new List <ObjComment>(); foreach (var item in listComment) { result.items.Add(MapComment(item)); } return(result); }
public ServiceResult <ObjFileData> UploadFile(int rootId, RootTypes rootType, IFormFile file, int?createdId) { var originalName = file.FileName.Trim(); var extension = Path.GetExtension(originalName); var fileName = Guid.NewGuid().ToString("N") + extension; var path = Path.Combine(CoreConfiguration.PathStorage, fileName); _fileHelper.SaveFile(file, path); var dbFile = new FileData() { FileName = fileName, OriginalName = originalName, CreatedId = createdId, RootId = rootId, RootType = rootType }; _fileDataRepository.Insert(dbFile); _fileDataRepository.SaveChanges(); return(ServiceResult <ObjFileData> .SuccessResult(Map(dbFile))); }
public IActionResult GetFinancesList(int rootId, RootTypes rootType) { var result = _financeService.GetList(rootId, rootType); return(Json(result)); }
public IActionResult GetProjectList(int rootId, RootTypes rootType) { var projectList = _projectService.GetProjectList(rootId, rootType); return(Json(projectList)); }
public IActionResult DeleteParticipant(int id, int rootId, RootTypes rootType) { _participantService.Delete(id); return(Json(_participantService.GetList(rootId, rootType))); }
public IEnumerable <Comment> GetByRootIDAndType(int rootId, RootTypes rootType) { var result = Queryable().Where(x => x.RootId == rootId && x.RootType == rootType).ToList(); return(result); }
public ObjTaskList GetTaskList(int rootID, RootTypes rootType) { ObjTaskList result = new ObjTaskList(); try { result.list = new List <ObjTask>(); var tasks = new List <Task>(); if (rootType == RootTypes.User) { var TasksIds = _participantRepository.GetList(rootID) .Select(x => x.RootId) .ToList(); foreach (var taskId in TasksIds) { tasks.Add(_taskRepository.GetFull(taskId)); } } else { tasks = _taskRepository.GetList(rootID, rootType); } result.list = tasks.Select(x => new ObjTask { Id = x.Id, RootId = x.RootId, RootType = x.RootType, Title = x.Title, Description = x.Description, StatusColor = x.Status.Color, StatusId = x.Status.Id, StatusName = x.Status.Name, CompeteProcent = x.CompeteProcent, DeadLine = x.DeadLine, TaskTypeName = x.TaskType.Name, TaskTypeId = x.TaskTypeId, UserId = x.UserId, Participants = _participantRepository.AllFull() .Where(particapant => particapant.RootType == RootTypes.Project && particapant.RootId == x.Id) .Select(participant => new ObjParticipant() { Id = participant.Id, FIO = participant.User.Fio, RootType = participant.RootType, Task = participant.Task, WorkSum = participant.WorkSum, Currency = participant.Currency, WorkPeriod = participant.WorkPeriod, Residue = participant.Residue, CreatedId = participant.CreatedId, UserId = participant.UserId, }) .ToList() }).ToList(); } catch (Exception ex) { _Logger.LogError("Getting Task list error rootId = {0} / RootType = {1} : {2}", rootID, rootType, ex); } return(result); }
public IActionResult DeleteContact(int id, int rootId, RootTypes rootType) { _contactService.DeleteContact(id); return(Json(_contactService.GetListContacts(rootId, rootType))); }
public IActionResult GetContactList(int rootId, RootTypes rootType) { return(Json(_contactService.GetListContacts(rootId, rootType))); }
public IActionResult GetParticipantList(int rootId, RootTypes rootType) { return(Json(_participantService.GetList(rootId, rootType))); }
public IEnumerable <Contact> GetByRootIdAndType(int rootID, RootTypes rootType) { return(Queryable().Where(x => x.RootID == rootID && x.RootType == rootType).ToList()); }