コード例 #1
0
        public async Task<ActionResult> Create(CustomerViewModel viewmodel)
        {
            if (ModelState.IsValid)
            {
                MSTCustomerDto cus = new MSTCustomerDto
                {
                    CustomerName = viewmodel.Name,
                    EndCustomer = viewmodel.EndCustomer,
                    Location = viewmodel.Location,
                    Strategic = viewmodel.Strategic,
                    LastUpdatedBy = CurrentName
                };
                var result = await CustomerRepository.AddAsync(cus);

                if (result == Model.SaveResult.SUCCESS)
                    return RedirectToAction("Index");
            }

            return View(viewmodel);
        }
コード例 #2
0
        public async Task<ActionResult> Edit(int id)
        {
            if (id == 0)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            MSTCustomerDto customer = await CustomerRepository.SingleAsync(id);
            if (customer == null)
                return HttpNotFound();
            CustomerViewModel bind = new CustomerViewModel
            {
                Name = customer.CustomerName,
                EndCustomer = customer.EndCustomer,
                Location = customer.Location,
                Strategic = customer.Strategic,
                LastUpdatedBy = customer.LastUpdatedBy,
                LastUpdate = customer.LastUpdate,
            };

            return View(bind);
        }