Exemplo n.º 1
0
 public static NotesServiceImpl.CustomerDTO ToServiceDTO(Models.CustomerDTO customer)
 {
     if (customer == null)
     {
         return(null);
     }
     return(new NotesServiceImpl.CustomerDTO
     {
         Guid = customer.Guid,
         Login = customer.Login,
         Password = customer.Password,
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         Email = customer.Email,
         LastLoginDate = customer.LastLoginDate
     });
 }
Exemplo n.º 2
0
        public IActionResult Post([FromBody] Models.CustomerDTO customer)
        {
            Customer newCust = new Customer();

            using (SweetDBContext db = new SweetDBContext())
            {
                newCust.Forename = customer.CustomerForename;
                newCust.Surname  = customer.CustomerSurname;
                newCust.Email    = customer.CustomerEmail;
                newCust.Created  = DateTime.Now;
                db.Customer.Add(newCust);
                var ret = db.SaveChanges();
            }

            return(Ok(new Models.CustomerDTO()
            {
                CustomerId = newCust.CustomerId, CustomerForename = newCust.Forename, CustomerSurname = newCust.Surname, CustomerEmail = newCust.Email
            }));
        }
Exemplo n.º 3
0
        public IActionResult Put(int id, [FromBody] Models.CustomerDTO customer)
        {
            using (SweetDBContext db = new SweetDBContext())
            {
                var cust = db.Customer.FirstOrDefault(r => r.CustomerId == id);
                if (cust != null)
                {
                    cust.Forename = customer.CustomerForename;
                    cust.Surname  = customer.CustomerSurname;
                    cust.Email    = customer.CustomerEmail;
                    db.SaveChanges();
                    return(Ok(new Models.CustomerDTO()
                    {
                        CustomerId = id, CustomerForename = cust.Forename, CustomerSurname = cust.Surname, CustomerEmail = cust.Email
                    }));
                }
            }

            return(NotFound());
        }