示例#1
0
        public ErrorCode Create(CompanyVM vm)
        {
            var company = new Company
            {
                Name = vm.Name.Trim(),
                FullName = vm.FullName.Trim(),
                Address = vm.Address.Trim(),
                Type = vm.Type,
                Comment = vm.Comment.Trim(),
                Zip = vm.Zip.Trim()
            };

            try
            {
                if (CompanyDal.GetExisted(o => o.Name == vm.Name && o.FullName == vm.FullName))
                {
                    return ErrorCode.CommodityTypeExisted;
                }
                CompanyDal.Create(company);
                return ErrorCode.NoError;
            }
            catch (Exception)
            {
                return ErrorCode.ServerError;
            }
        }
示例#2
0
 public ActionResult Create(int id)
 {
     ViewBag.Title = id == (int)CustomerType.Customer ? "客户公司" : "内部公司";
     ViewBag.Id = 0;
     var company = new CompanyVM { Type = id };
     return View("CompanyInfo", company);
 }
示例#3
0
        public ActionResult Create(CompanyVM company)
        {
            if (ModelState.IsValid)
            {
                var result = CompanySvc.Create(company);
                return MyAjaxHelper.RedirectAjax(result, "");
            }

            var error = ModelState.Values.First(o => o.Errors.Count > 0).Errors[0].ErrorMessage;
            return MyAjaxHelper.RedirectAjax(AjaxStatusCode.Error, error, null, "");
        }
示例#4
0
        public CompanyVM GetById(int id)
        {
            Company company = CompanyDal.GetById(id, null);
            if (company != null)
            {
                var res = new CompanyVM
                              {
                                  Id = company.Id,
                                  Name = company.Name,
                                  FullName = company.FullName,
                                  Address = company.Address,
                                  Zip = company.Zip,
                                  Comment = company.Comment,
                                  Type = company.Type
                              };
                return res;
            }

            return null;
        }