Exemplo n.º 1
0
        public ActionResult ModifyCustomer(Models.Customer.Customer model)
        {
            if (ModelState.IsValid)
            {
                var result = _customers.SaveCustomer(new CustomerSave()
                {
                    City         = model.City,
                    CustomerId   = model.CustomerId,
                    EmailAddress = model.EmailAddress,
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    PhoneNumber  = model.PhoneNumber,
                    State        = model.State,
                    StoreId      = model.StoreId,
                    UserId       = userId,
                    ZipCode      = model.ZipCode
                });

                if (result.IsSuccess)
                {
                    return(RedirectToAction("Customers", new { id = model.StoreId }));
                }
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <(bool, Models.Customer.Customer)> Get(int Id)
        {
            Models.Customer.Customer customer = null;

            var parameters = new DynamicParameters();

            parameters.Add("@CustomerId", Id, DbType.Int32, ParameterDirection.Input);

            try
            {
                using (var connection = new SqlConnection(_connectionString))
                {
                    customer = await connection.QuerySingleAsync <Models.Customer.Customer>(
                        "[dbo].[Customer_GetById]",
                        parameters,
                        commandType : CommandType.StoredProcedure)
                               .ConfigureAwait(false);
                }
            }
            catch
            {
                return(false, null);
            }

            return(true, customer);
        }
Exemplo n.º 3
0
        public ActionResult Home(string id)
        {
            Guid?customerId = Migi.Framework.Helper.Types.GetNullableGuid(id);

            if (customerId.HasValue)
            {
                Models.Customer.Customer customerViewModel = new Models.Customer.Customer(_customers.GetCustomer(customerId.Value));
                return(View(customerViewModel));
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Home(string id)
        {
            Guid? customerId = Migi.Framework.Helper.Types.GetNullableGuid(id);

            if (customerId.HasValue)
            {
                Models.Customer.Customer customerViewModel = new Models.Customer.Customer(_customers.GetCustomer(customerId.Value));
                return View(customerViewModel);
            }
            return new HttpNotFoundResult();
        }
Exemplo n.º 5
0
        public ActionResult ModifyCustomer(Guid storeId, string id)
        {
            Guid?customerId = Migi.Framework.Helper.Types.GetNullableGuid(id);

            Customer customer = null;

            if (customerId.HasValue)
            {
                customer = _customers.GetCustomer(customerId.Value);
            }

            Models.Customer.Customer model = new Models.Customer.Customer(customer);
            return(View(model));
        }
Exemplo n.º 6
0
        public async Task <bool> Save(Models.Customer.Customer customer, SaveType saveType)
        {
            var parameters = new DynamicParameters();

            parameters.Add("@FirstName", customer.FirstName);
            parameters.Add("@Surname", customer.Surname);
            parameters.Add("@DateOfBirth", customer.DateOfBirth);
            parameters.Add("@TelephoneNumber", customer.TelephoneNumber);

            var storedProcedure = string.Empty;

            switch (saveType)
            {
            case SaveType.Insert:
                storedProcedure = "[dbo].[Customer_Insert]";
                break;

            case SaveType.Update:
                parameters.Add("@CustomerId", customer.Id);
                storedProcedure = "[dbo].[Customer_Update]";
                break;
            }

            try
            {
                using (var connection = new SqlConnection(_connectionString))
                {
                    await connection.QueryAsync(
                        storedProcedure,
                        parameters,
                        commandType : CommandType.StoredProcedure)
                    .ConfigureAwait(false);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public ActionResult ModifyCustomer(Guid storeId, string id)
        {
            Guid? customerId = Migi.Framework.Helper.Types.GetNullableGuid(id);

            Customer customer = null;

            if (customerId.HasValue)
                customer = _customers.GetCustomer(customerId.Value);

            Models.Customer.Customer model = new Models.Customer.Customer(customer);
            return View(model);
        }
Exemplo n.º 8
0
 public async Task <bool> Insert(Models.Customer.Customer customer)
 {
     return(await _customerRepository.Save(customer, SaveType.Insert).ConfigureAwait(false));
 }