Example #1
0
        public ActionResult Summary(CustomerModel model)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            model.Fill(reader.GetByID(model.ID));
            return(View(CustomerController.EditView, model));
        }
Example #2
0
        public ActionResult Summary(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer = CustomerInfo.GetByID(model.ID);
            model.Fill(customer);

            return(View(CustomerController.EditView, model));
        }
        public CustomerModel Put(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer.Fill(model);
            customer.Save();      // Save screen changes to database.
            model.Fill(customer); // Go back to model for transport

            return(model);
        }
Example #4
0
        public ActionResult Create(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer.Fill(model);
            customer.Save();      // Save screen changes to database.
            model.Fill(customer); // Fill the CustomerModel view model, so the class can be specific to the screen's needs and drop the heavy data access items.

            return(View(CustomerController.SummaryView, model));
        }
Example #5
0
        public CustomerModel Post(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer = CustomerInfo.GetByID(model.ID);
            customer.Fill(model); // Overlay all screen edits on-top of the data-access-object, to preserve untouched original data
            customer.Save();
            model.Fill(customer); // Go back to model for transport

            return(model);
        }
Example #6
0
        public ActionResult Edit(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer = CustomerInfo.GetByID(model.ID);
            customer.Fill(model); // Overlay all screen edits on-top of the data-access-object, to preserve untouched original data
            customer.Save();
            model.Fill(customer); // Go back to screen model for ui-specific functionality to be available to view/page

            return(View(CustomerController.SummaryView, model));
        }
Example #7
0
        public CustomerModel Delete(string id)
        {
            CustomerInfo  customer = new CustomerInfo();
            CustomerModel model    = new CustomerModel();

            customer = CustomerInfo.GetByID(id.TryParseInt32());
            if (customer.ID != TypeExtension.DefaultInteger)
            {
                model.Fill(customer); // Go back to model for transport
            }

            return(model);
        }
        public CustomerModel Post(CustomerModel model)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            CustomerInfo customer = new CustomerInfo();

            customer = reader.GetByID(model.ID);
            customer.Fill(model); // Overlay all screen edits on-top of the data-access-object, to preserve untouched original data
            customer.Save();
            model.Fill(customer); // Go back to model for transport

            return(model);
        }
Example #9
0
        public async Task Endpoints_WebApi_CustomerPut()
        {
            var customerToCreate = new CustomerModel();
            var url = new Uri(new ConfigurationManagerLocal().AppSettingValue("MyWebService").AddLast("/Customer"));

            customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]);
            var request = new HttpRequestPut <CustomerModel>(url, customerToCreate);

            customerToCreate = await request.SendAsync();

            Assert.IsTrue(interfaceBreakingRelease || !customerToCreate.IsNew);
            WebApiEndpointsTests.RecycleBin.Add(customerToCreate.Key);
        }
Example #10
0
        public ActionResult Summary(string id)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            var model = new CustomerModel();

            model.Fill(reader.GetByID(id.TryParseInt32()));
            if (model.ID == TypeExtension.DefaultInteger)
            {
                ModelState.AddModelError("", "No customer found");
            }
            return(View(CustomerController.SummaryView, model));
        }
        public async Task Endpoints_Framework_WebAPI_CustomerPut()
        {
            var customerToCreate = new CustomerModel();
            var url = new Uri(new ConfigurationManagerFull().AppSettingValue("MyWebService").AddLast("/Customer"));

            customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]);
            var request = new HttpRequestPut <CustomerModel>(url, customerToCreate);

            customerToCreate = await request.SendAsync();

            Assert.IsTrue(!customerToCreate.IsNew);
            Endpoints_Framework_for_WebApi.RecycleBin.Add(customerToCreate.ID);
        }
        public CustomerModel Delete(string id)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            CustomerInfo  customer = new CustomerInfo();
            CustomerModel model    = new CustomerModel();

            customer = reader.GetByID(id.TryParseInt32());
            customer.Delete();
            customer = reader.GetByID(id.TryParseInt32()); // Verify delete, success returns empty object
            model.Fill(customer);

            return(model);
        }
Example #13
0
        public async Task Full_ViewModel_CRUD_Create()
        {
            var customer = new CustomerModel();
            var url      = new Uri(new ConfigurationManagerLocal().AppSettingValue("MyWebService").AddLast("/Customer"));

            customer.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]);
            var request = new HttpRequestPut <CustomerModel>(url, customer);

            customer = await request.SendAsync();

            Assert.IsTrue(interfaceBreakingRelease | customer.Id != TypeExtension.DefaultInteger);
            Assert.IsTrue(interfaceBreakingRelease | customer.Key != TypeExtension.DefaultGuid);

            RecycleBin.Add(customer.Key);
        }
        public CustomerModel Get(string id)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            CustomerInfo  customer = new CustomerInfo();
            CustomerModel model    = new CustomerModel();

            customer = reader.GetByID(id.TryParseInt32());
            if (customer.ID != TypeExtension.DefaultInteger)
            {
                model.Fill(customer); // Go back to model for transport
            }

            return(model);
        }
Example #15
0
        public ActionResult Delete(string id)
        {
            CustomerInfo  customer = new CustomerInfo();
            CustomerModel model    = new CustomerModel();

            customer = CustomerInfo.GetByID(id.TryParseInt32());
            if (customer.ID != TypeExtension.DefaultInteger)
            {
                model.Fill(customer); // Fill the CustomerModel view model, so the class can be specific to the screen's needs and drop the heavy data access items.
            }
            else
            {
                ModelState.AddModelError("", "No customer found");
            }

            return(View(CustomerController.DeleteView, model));
        }
Example #16
0
        public ActionResult Create(CustomerModel model)
        {
            var customer = new CustomerInfo();

            customer.Fill(model);
            customer.Save();      // Save screen changes to database.
            model.Fill(customer); // Fill the CustomerModel view model, so the class can be specific to the screen's needs and drop the heavy data access items.
            if (customer.IsNew == false)
            {
                ModelState.AddModelError("", "Successfully created");
            }
            else
            {
                ModelState.AddModelError("", "Failed to create");
            }

            return(View(CustomerController.SummaryView, model));
        }
Example #17
0
        public async Task Customer_Cloud_CustomerPut()
        {
            CustomerModel customerToCreate = new CustomerModel();
            string        urlRoot          = new ConfigurationManagerFull().AppSettingValue("MyWebService");
            string        urlFull          = String.Format("{0}/{1}", urlRoot, "Customer");
            HttpRequestPut <CustomerModel> request;

            // Simulate the service layer transforming the Model (CustomerModel) to the Data Access Object (CustomerInfo)
            customerToCreate.Fill(customerTestData[Arithmetic.Random(1, 5)]);
            // Call the cloud and get results
            request          = new HttpRequestPut <CustomerModel>(urlFull, customerToCreate);
            customerToCreate = await request.SendAsync();

            Assert.IsTrue(customerToCreate.ID != TypeExtension.DefaultInteger, "Customer did not save.");
            Assert.IsTrue(customerToCreate.Key != TypeExtension.DefaultGuid, "Customer did not save.");

            // Inserted records must be added to recycle bin for cleanup
            recycleBin.Add(customerToCreate.ID);
        }
Example #18
0
        public ActionResult Delete(CustomerModel model)
        {
            CustomerInfo customer = new CustomerInfo();

            customer = CustomerInfo.GetByID(model.ID);
            customer.Delete();
            customer = CustomerInfo.GetByID(model.ID);
            if (customer.ID == TypeExtension.DefaultInteger)
            {
                model.Fill(customer); // Fill the CustomerModel view model, so the class can be specific to the screen's needs and drop the heavy data access items.
                ModelState.AddModelError("", "Successfully deleted");
            }
            else
            {
                ModelState.AddModelError("", "Failed to delete");
            }

            return(View(CustomerController.DeleteView, model));
        }
Example #19
0
        public async Task Endpoints_Framework_WebAPI_CustomerPut()
        {
            var customerToCreate = new CustomerModel();
            var returnedItem     = new CustomerModel();
            var url = new Uri(new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer"));

            try
            {
                customerToCreate.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]);
                var request = new HttpRequestPut <CustomerModel>(url, customerToCreate);
                returnedItem = await request.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease || customerToCreate != null);
                Endpoints_Framework_for_WebApi.RecycleBin.Add(customerToCreate.Key);
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }
        }
Example #20
0
        public ActionResult Delete(CustomerModel model)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            var customer = new CustomerInfo();

            customer = reader.GetByID(model.ID);
            customer.Delete();
            customer = reader.GetByID(model.ID); // Verify delete, success returns empty object
            if (customer.ID == TypeExtension.DefaultInteger)
            {
                model.Fill(customer); // Fill the CustomerModel view model, so the class can be specific to the screen's needs and drop the heavy data access items.
                ModelState.AddModelError("", "Successfully deleted");
            }
            else
            {
                ModelState.AddModelError("", "Failed to delete");
            }

            return(View(CustomerController.SummaryView, model));
        }
Example #21
0
        public ActionResult Edit(CustomerModel model)
        {
            var reader = ReadOnlyDatabase <CustomerInfo> .Construct();

            var customer = new CustomerInfo();

            customer = reader.GetByID(model.ID);
            customer.Fill(model); // Overlay all screen edits on-top of the data-access-object, to preserve untouched original data
            customer.Save();
            model.Fill(customer); // Go back to screen model for ui-specific functionality to be available to view/page
            if (customer.IsNew == false)
            {
                ModelState.AddModelError("", "Successfully saved");
            }
            else
            {
                ModelState.AddModelError("", "Failed to save");
            }

            return(View(CustomerController.SummaryView, model));
        }
Example #22
0
        public async Task Core_ViewModel_CRUD_Create()
        {
            var customer = new CustomerModel();
            var url      = new Uri(new ConfigurationManagerCore(ApplicationTypes.Native).AppSettingValue("MyWebService").AddLast("/Customer"));

            try
            {
                customer.Fill(customerTestData[Arithmetic.Random(1, customerTestData.Count)]);
                var request = new HttpRequestPut <CustomerModel>(url, customer);
                customer = await request.SendAsync();

                Assert.IsTrue(interfaceBreakingRelease | customer.Id != Defaults.Integer);
                Assert.IsTrue(interfaceBreakingRelease | customer.Key != Defaults.Guid);
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }

            RecycleBin.Add(customer.Key);
        }