Exemple #1
0
        //Register new customer and converting from viewmodel to domain model, returns int to redirect to edit page after the new account is created
        public int Register(RedbetCustomerViewModel model)
        {
            var dbCustomer = new redbetCustomer()
            {
                Id           = model.Id,
                Firstname    = model.Firstname,
                Lastname     = model.Lastname,
                Street       = model.Street,
                City         = model.City,
                PostalCode   = model.PostalCode,
                FavoriteTeam = model.FavoriteTeam
            };

            return(repo.Insert(dbCustomer));
        }
Exemple #2
0
        //Updating customer and converting from viewmodel to domain model
        public void Update(RedbetCustomerViewModel model)
        {
            var dbCustomer = new redbetCustomer()
            {
                Id           = model.Id,
                Firstname    = model.Firstname,
                Lastname     = model.Lastname,
                Street       = model.Street,
                City         = model.City,
                PostalCode   = model.PostalCode,
                FavoriteTeam = model.FavoriteTeam
            };

            repo.Update(dbCustomer);
        }
Exemple #3
0
        //Updating customer
        public void Update(redbetCustomer entity)
        {
            var existCust = Find(entity.Id);

            if (existCust == null)
            {
                db.RedbetCustomers.Add(entity);
            }
            else
            {
                existCust.Id           = entity.Id;
                existCust.Firstname    = entity.Firstname;
                existCust.Lastname     = entity.Lastname;
                existCust.Street       = entity.Street;
                existCust.PostalCode   = entity.PostalCode;
                existCust.City         = entity.City;
                existCust.FavoriteTeam = entity.FavoriteTeam;
            }
            Save();
        }