Ejemplo n.º 1
0
        public async Task <bool> UpdatCustomerAsync(int id, CommandCustomerModel customer)
        {
            var customerEntity = await _context.Customer.FindAsync(id);

            if (customerEntity != null)
            {
                customerEntity.Address               = customer.Address;
                customerEntity.City                  = customer.City;
                customerEntity.Country               = customer.Country;
                customerEntity.FirstName             = customer.FirstName;
                customerEntity.LastName              = customer.LastName;
                customerEntity.Phone                 = customer.Phone;
                customerEntity.PostalCode            = customer.PostalCode;
                customerEntity.State                 = customer.State;
                _context.Entry(customerEntity).State = EntityState.Modified;
            }
            else
            {
                throw new Exception("Customer does not exists.");
            }

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Something went wrong, please contact system administrator.");
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> UpdatTicketAsync(int id, CommandTicketModel ticket)
        {
            var ticketEntity = await _context.Ticket.FindAsync(id);

            if (ticketEntity != null)
            {
                ticketEntity.IssueStartedOn        = ticket.IssueStartedOn;
                ticketEntity.Status                = ticket.Status;
                ticketEntity.Subject               = ticket.Subject;
                ticketEntity.Category              = ticket.Category;
                ticketEntity.CustomerId            = ticket.CustomerId;
                ticketEntity.Description           = ticket.Description;
                _context.Entry(ticketEntity).State = EntityState.Modified;
            }
            else
            {
                throw new Exception("Ticket does not exists.");
            }

            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Something went wrong, please contact system administrator.");
            }
        }