public async Task <ActionResult> Delete(int?id)  //GET: /CustomerDepartments
        {
            if (id == null)
            {
                return(BadRequestTextResult());
            }
            CustomerDepartment customerDepartment = await FindAsyncCustomerDepartment(id.Value);

            if (customerDepartment == null)
            {
                return(NotFoundTextResult());
            }

            DataContext.CustomerDepartments.Remove(customerDepartment);
            try
            {
                await DataContext.SaveChangesAsync(this);
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();
                sb.Append(MessageStrings.CanNotDelete);
                sb.Append(customerDepartment.DepartmentName);
                sb.Append("<br/>");
                AppendExceptionMsg(ex, sb);

                return(StatusCodeTextResult(sb, HttpStatusCode.InternalServerError));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        public async Task <ActionResult> Edit(CustomerDepartment customerDepartment, bool?modal)
        {
            if (ModelState.IsValid)
            {
                OnEditSaving(customerDepartment);

                DataContext.Entry(customerDepartment).State = EntityState.Modified;
                await DataContext.SaveChangesAsync(this);

                OnEditSaved(customerDepartment);
                if (modal ?? false)
                {
                    return(Json(new { saved = true }));
                }
                return(RedirectToAction("Index", new { customerId = customerDepartment.CustomerId }));
            }

            SetSelectLists(customerDepartment);
            if (modal ?? false)
            {
                ViewBag.Modal = true;
                return(PartialView("_Edit", customerDepartment));
            }
            return(View(customerDepartment));
        }
        public async Task <ActionResult> Create(int?customerId, CustomerDepartment customerDepartment, bool?modal)
        {
            if (ModelState.IsValid)
            {
                OnCreateSaving(customerDepartment);

                DataContext.CustomerDepartments.Add(customerDepartment);
                await DataContext.SaveChangesAsync(this);

                OnCreateSaved(customerDepartment);
                if (modal ?? false)
                {
                    return(Json(new { saved = true }));
                }
                return(RedirectToAction("Index", new { customerId = customerDepartment.CustomerId }));
            }

            SetSelectLists(customerDepartment);
            if (modal ?? false)
            {
                ViewBag.Modal = true;
                return(PartialView("_Create", customerDepartment));
            }
            return(View(customerDepartment));
        }
        public async Task <ActionResult> Create(int?customerId, bool?modal)
        {
            var customerDepartment = new CustomerDepartment();

            if (customerId != null)
            {
                var customer = await FindAsyncCustomer(customerId.Value);

                if (customer == null)
                {
                    return(HttpNotFound());
                }
                customerDepartment.Customer   = customer;
                customerDepartment.CustomerId = customerId.Value;
            }
            await SetCustomerDepartmentDefaults(customerDepartment);

            SetSelectLists(customerDepartment);
            if (modal ?? false)
            {
                ViewBag.Modal = true;
                return(PartialView("_Create", customerDepartment));
            }
            return(View(customerDepartment));
        }
示例#5
0
        private CustomerDepartmentEditModel BuildCustomerDepartmentEditModelAC(CustomerDepartment cdentity)
        {
            CustomerDepartmentEditModel strCustDeptList = new CustomerDepartmentEditModel();

            strCustDeptList.CustomerDepartmentName = cdentity.Customer.CustomerCompanyName + " - ";
            strCustDeptList.CustomerDepartmentName = strCustDeptList.CustomerDepartmentName + cdentity.CustomerDepartmentName;
            strCustDeptList.CustomerDepartmentID   = cdentity.CustomerDepartmentID;
            strCustDeptList.CustomerCompanyName    = cdentity.Customer.CustomerCompanyName;
            return(strCustDeptList);
        }
        public async Task <ActionResult> GetCustomerDepartment(int?id)
        {
            if (id == null)
            {
                return(BadRequestTextResult());
            }
            CustomerDepartment customerDepartment = await FindAsyncCustomerDepartment(id.Value);

            if (customerDepartment == null)
            {
                return(NotFoundTextResult());
            }

            return(Json(new CustomerDepartmentDTO(customerDepartment), JsonRequestBehavior.AllowGet));
        }
示例#7
0
        private void InsertCustomerDepartmentLocation(CustomerDepartment depaItem, List <Guid> locaGuidList)
        {
            var item = new CustomerDepartmentLocation();

            item.CustomerDepartmentLocationID = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]);
            item.CustomerDepartmentID         = depaItem.CustomerDepartmentID;
            item.CreatedBy   = depaItem.CreatedBy;
            item.CreatedDate = depaItem.CreatedDate;
            item.UpdatedBy   = depaItem.UpdatedBy;
            item.UpdatedDate = depaItem.UpdatedDate;
            foreach (var locaGuid in locaGuidList)
            {
                item.CustomerLocationID = locaGuid;
                _customerDepartmentLocationService.Insert(item);
            }
        }
        public async Task <ActionResult> Edit(int?id, bool?modal)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CustomerDepartment customerDepartment = await FindAsyncCustomerDepartment(id.Value);

            if (customerDepartment == null)
            {
                return(HttpNotFound());
            }

            SetSelectLists(customerDepartment);
            if (modal ?? false)
            {
                ViewBag.Modal = true;
                return(PartialView("_Edit", customerDepartment));
            }
            return(View(customerDepartment));
        }
示例#9
0
 protected virtual Task SetCustomerDepartmentDefaults(CustomerDepartment customerDepartment)
 {
     return(Task.FromResult(default(object)));
 }
示例#10
0
 public void AddCustomerDepartment(CustomerDepartment customerDepartment)
 {
     _context.CustomerDepartments.Add(customerDepartment);
 }
 partial void SetSelectLists(CustomerDepartment customerDepartment);
 partial void OnEditSaved(CustomerDepartment customerDepartment);
 partial void OnCreateSaved(CustomerDepartment customerDepartment);