Ejemplo n.º 1
0
        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("Ошибка при загрузке данных"));
            }
        }
Ejemplo n.º 2
0
 public List <Participant> Get(int rootId, RootTypes rootType)
 {
     return(Queryable <Participant>()
            .Where(p => p.RootId == rootId && p.RootType == rootType)
            .Include(x => x.User)
            .ToList());
 }
Ejemplo n.º 3
0
        public List <Status> Get(RootTypes rootType)
        {
            var result = Queryable()
                         .Where(status => status.rootType == rootType)
                         .ToList();

            return(result);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 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());
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public List <ObjStatus> GetStatusesByRootType(RootTypes rootType)
        {
            var statuses = _statusRepository.Get(rootType);

            return(statuses
                   .Select(x => Map(x))
                   .OrderBy(x => x.Position)
                   .ToList());
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        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));
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
0
        public string GetRootUrl(RootTypes rootType, int rootId)
        {
            string result = string.Empty;

            switch (rootType)
            {
            case RootTypes.Client:
                result = "/Clients/Details/" + rootId;
                break;
            }
            return(result);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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));
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        public bool IsRootType(ITypeDefinitionNode typeDefinition)
        {
            if (typeDefinition == null)
            {
                throw new ArgumentNullException(nameof(typeDefinition));
            }

            if (typeDefinition is ObjectTypeDefinitionNode ot)
            {
                return(RootTypes.ContainsValue(ot));
            }

            return(false);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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)));
        }
Ejemplo n.º 22
0
        public IActionResult GetFinancesList(int rootId, RootTypes rootType)
        {
            var result = _financeService.GetList(rootId, rootType);

            return(Json(result));
        }
Ejemplo n.º 23
0
        public IActionResult GetProjectList(int rootId, RootTypes rootType)
        {
            var projectList = _projectService.GetProjectList(rootId, rootType);

            return(Json(projectList));
        }
Ejemplo n.º 24
0
 public IActionResult DeleteParticipant(int id, int rootId, RootTypes rootType)
 {
     _participantService.Delete(id);
     return(Json(_participantService.GetList(rootId, rootType)));
 }
Ejemplo n.º 25
0
        public IEnumerable <Comment> GetByRootIDAndType(int rootId, RootTypes rootType)
        {
            var result = Queryable().Where(x => x.RootId == rootId && x.RootType == rootType).ToList();

            return(result);
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
 public IActionResult DeleteContact(int id, int rootId, RootTypes rootType)
 {
     _contactService.DeleteContact(id);
     return(Json(_contactService.GetListContacts(rootId, rootType)));
 }
Ejemplo n.º 28
0
 public IActionResult GetContactList(int rootId, RootTypes rootType)
 {
     return(Json(_contactService.GetListContacts(rootId, rootType)));
 }
Ejemplo n.º 29
0
 public IActionResult GetParticipantList(int rootId, RootTypes rootType)
 {
     return(Json(_participantService.GetList(rootId, rootType)));
 }
Ejemplo n.º 30
0
 public IEnumerable <Contact> GetByRootIdAndType(int rootID, RootTypes rootType)
 {
     return(Queryable().Where(x => x.RootID == rootID && x.RootType == rootType).ToList());
 }