Ejemplo n.º 1
0
        public async Task <bool> Create(CustomerPhone CustomerPhone)
        {
            CustomerPhoneDAO CustomerPhoneDAO = new CustomerPhoneDAO();

            CustomerPhoneDAO.Id          = CustomerPhone.Id;
            CustomerPhoneDAO.CustomerId  = CustomerPhone.CustomerId;
            CustomerPhoneDAO.Phone       = CustomerPhone.Phone;
            CustomerPhoneDAO.PhoneTypeId = CustomerPhone.PhoneTypeId;
            DataContext.CustomerPhone.Add(CustomerPhoneDAO);
            await DataContext.SaveChangesAsync();

            CustomerPhone.Id = CustomerPhoneDAO.Id;
            await SaveReference(CustomerPhone);

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <bool> BulkMerge(List <CustomerPhone> CustomerPhones)
        {
            List <CustomerPhoneDAO> CustomerPhoneDAOs = new List <CustomerPhoneDAO>();

            foreach (CustomerPhone CustomerPhone in CustomerPhones)
            {
                CustomerPhoneDAO CustomerPhoneDAO = new CustomerPhoneDAO();
                CustomerPhoneDAO.Id          = CustomerPhone.Id;
                CustomerPhoneDAO.CustomerId  = CustomerPhone.CustomerId;
                CustomerPhoneDAO.Phone       = CustomerPhone.Phone;
                CustomerPhoneDAO.PhoneTypeId = CustomerPhone.PhoneTypeId;
                CustomerPhoneDAOs.Add(CustomerPhoneDAO);
            }
            await DataContext.BulkMergeAsync(CustomerPhoneDAOs);

            return(true);
        }
Ejemplo n.º 3
0
        public async Task <bool> Update(CustomerPhone CustomerPhone)
        {
            CustomerPhoneDAO CustomerPhoneDAO = DataContext.CustomerPhone.Where(x => x.Id == CustomerPhone.Id).FirstOrDefault();

            if (CustomerPhoneDAO == null)
            {
                return(false);
            }
            CustomerPhoneDAO.Id          = CustomerPhone.Id;
            CustomerPhoneDAO.CustomerId  = CustomerPhone.CustomerId;
            CustomerPhoneDAO.Phone       = CustomerPhone.Phone;
            CustomerPhoneDAO.PhoneTypeId = CustomerPhone.PhoneTypeId;
            await DataContext.SaveChangesAsync();

            await SaveReference(CustomerPhone);

            return(true);
        }