Esempio n. 1
0
        public static NotificationVm ToModel(this Notfication entity, AdamUnit adamUnit)
        {
            var NofiVM = new NotificationVm();

            NofiVM.Id         = entity.Id;
            NofiVM.Context    = entity.Context;
            NofiVM.NameOfSend = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == entity.OwnerUserId).FirstName;
            var userIdAdmin = adamUnit.RoleRepository.GetUserIdOfRole();

            if (userIdAdmin == entity.OwnerUserId)
            {
                NofiVM.filename = adamUnit.AttachmentRepository.FirstOrDefault(x => x.OwnerId == userIdAdmin.ToString() && x.AttachmentOwner == AttachmentOwner.Employees).FileName;
            }
            else
            {
                var employeeId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.UserId == entity.OwnerUserId).Id;
                NofiVM.filename = adamUnit.AttachmentRepository.SingleOrDefault(x => x.OwnerId == employeeId.ToString() && x.AttachmentOwner == AttachmentOwner.Employees).FileName;
            }

            NofiVM.TableName = entity.TableName.GetDisplayName();
            NofiVM.TablePkId = entity.TablePkId;
            NofiVM.IsRead    = entity.IsRead;
            NofiVM.Date      = entity.CreationDate.ToShortTimeString();
            return(NofiVM);
        }
Esempio n. 2
0
        public static ProjectVM ToModelReport(this Project entity, AdamUnit adamUnit, ProjectVM model)
        {
            model.Id   = entity.Id;
            model.Name = entity.Name;
            var listName = " ";

            foreach (var id in model.EmlpSelected)
            {
                var UserId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == id).UserId;
                var Name   = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == UserId).FirstName;
                listName += " " + Name;
            }
            model.EmplyeeName = listName;


            return(model);
        }
Esempio n. 3
0
        public static ProjectVM ToModel(this Project entity, AdamUnit adamUnit)
        {
            var project = new ProjectVM();

            project.Id           = entity.Id;
            project.Name         = entity.Name;
            project.CustomerName = entity.Customer.FirstName;

            var IdsProjects = adamUnit.ProjectUserRepository.GetAll(x => x.ProjectId == entity.Id).Select(x => x.UserId);
            var listName    = " ";

            foreach (var id in IdsProjects)
            {
                var UserId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == id).UserId;
                var Name   = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == UserId).FirstName;
                listName += " " + Name;
            }
            project.EmplyeeName = listName;
            return(project);
        }
Esempio n. 4
0
        public static ProjectVM ToModelEmp(this Project entity, AdamUnit adamUnit, string CurrentUserId)
        {
            var EmployeeId  = adamUnit.EmployeeRepository.SingleOrDefault(x => x.UserId == CurrentUserId).Id;
            var project     = new ProjectVM();
            var ProjectUser = adamUnit.ProjectUserRepository.SingleOrDefault(x => x.ProjectId == entity.Id && x.UserId == EmployeeId);
            var listName    = " ";

            if (ProjectUser != null)
            {
                var UserId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == ProjectUser.UserId).UserId;
                if (UserId == CurrentUserId)
                {
                    var Name = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == UserId).FirstName;
                    listName           += " " + Name;
                    project.Id          = entity.Id;
                    project.Name        = entity.Name;
                    project.EmplyeeName = listName;
                }
            }

            return(project);
        }
Esempio n. 5
0
        public static CommentVm ToModel(this Comment entity, AdamUnit adamUnit)
        {
            var comment = new CommentVm();

            comment.id        = entity.Id;
            comment.context   = entity.context;
            comment.firstName = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == entity.UserId).FirstName;
            comment.lastName  = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == entity.UserId).LastName;
            comment.date      = entity.CreationDate.ToShortTimeString();
            comment.tableId   = entity.TableId;
            var userIdAdmin = adamUnit.RoleRepository.GetUserIdOfRole();

            if (userIdAdmin == entity.UserId)
            {
                comment.attachment = adamUnit.AttachmentRepository.FirstOrDefault(x => x.OwnerId == userIdAdmin.ToString() && x.AttachmentOwner == AttachmentOwner.Employees).FileName;
            }
            else
            {
                var employeeId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.UserId == entity.UserId).Id;
                comment.attachment = adamUnit.AttachmentRepository.SingleOrDefault(x => x.OwnerId == employeeId.ToString()).FileName;
            }
            return(comment);
        }