コード例 #1
0
 public static CustomerModel GetModelFromContract(CustomerContractsModel customer)
 {
     return(new CustomerModel
     {
         Id = customer.Id,
         FirestName = customer.FirestName,
         MiddleName = customer.MiddleName,
         LastName = customer.LastName,
         PassportNumber = customer.PassportNumber,
         BirthDate = customer.BirthDate
     });
 }
コード例 #2
0
        public bool Add(CustomerContractsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            using (_context)
            {
                this._customer = ModelConverterHelper.GetModelFromContract(model);
                this._context.Customer.Add(this._customer);
            }

            return(true);
        }
コード例 #3
0
        public bool Save(CustomerContractsModel customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }

            this._customer = ModelConverterHelper.GetModelFromContract(customer);

            using (_context)
            {
                var customerModel = _context.Customer.FirstOrDefault(x => x.Id == this._customer.Id);
                customerModel = _customer;
                _context.SaveChanges();
            }

            return(true);
        }