Ejemplo n.º 1
0
        public async Task CreateCompany(CreateCompanyBindingModel model)
        {
            var company = new Company();

            company.Name      = model.Name;
            company.IsDeleted = model.IsDeleted;

            await dbContext.Companies.AddAsync(company);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task CreateProject(CreateProjectBindingModel model)
        {
            var newProject = new Project();

            newProject.Id          = model.Id;
            newProject.Title       = model.Title;
            newProject.Description = model.Description;
            newProject.CompanyId   = model.CompanyId;
            newProject.WorkTime    = model.WorkTime;
            newProject.IsDeleted   = model.IsDelete;

            await dbContext.Projects.AddAsync(newProject);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task EditUser(EditUserBindingModel model)
        {
            var editUser = await FindUser(model.Id);

            if (editUser == null)
            {
                throw new NullReferenceException();
            }
            editUser.UserName  = model.Username;
            editUser.CompanyId = model.CompanyId;
            editUser.IsDelete  = model.IsDeleted;
            editUser.IsGlobal  = model.IsGlobal;

            dbContext.Update(editUser);
            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 4
0
        public async Task CreateTicket(CreateTicketBindingModel model)
        {
            var newTicket = new Ticket();
            //Here i give default values on the Priority and Agent because these are props only accessed by Admin

            string username = "******";
            var    agent    = await FindUserIdByUserName(username);

            newTicket.AgentId = agent.Id;

            newTicket.Title      = model.Title;
            newTicket.Priority   = model.Priority;
            newTicket.Descripton = model.Description;
            newTicket.ProjectId  = model.ProjectId;
            newTicket.AuthorId   = model.AuthorId;
            newTicket.SendOn     = model.SendOn;

            await _dbContext.Tickets.AddAsync(newTicket);

            await _dbContext.SaveChangesAsync();
        }
Ejemplo n.º 5
0
        public async Task CreateTicket(Admin.ViewModels.Ticket.CreateTicketBindingModel model)
        {
            var ticket = new Ticket();

            if (model.AgentId != null)
            {
                ticket.AgentId = model.AgentId;
            }
            else
            {
                string username     = "******";
                var    defaultAgent = await FindUserIdByName(username);

                ticket.AgentId = defaultAgent.Id;
            }


            ticket.AuthorId   = model.AuthorId;
            ticket.Title      = model.Title;
            ticket.Descripton = model.Descripton;
            ticket.SendOn     = model.SendOn;
            ticket.Priority   = model.Priority;
            ticket.ProjectId  = model.ProjectId;

            await dbContext.Tickets.AddAsync(ticket);

            await dbContext.SaveChangesAsync();
        }
Ejemplo n.º 6
0
        private async Task SeedCompanyAsync(TicketMasterDbContext dbContext)
        {
            var company = dbContext.Companies.FirstOrDefault(c => c.Name == "GlobalInc");

            if (company == null)
            {
                var result = dbContext.Companies.Add(new Company
                {
                    Name      = "GlobalInc",
                    IsDeleted = false,
                });
                await dbContext.SaveChangesAsync();
            }
        }