예제 #1
0
        public JsonResult AddCustomer(CustomerViewModel cms)
        {
            string a         = "";
            string power     = Session["Power"].ToString();
            string empid     = Session["LoginId"].ToString();
            var    sa        = new SAViewModel();
            var    userpower = new List <string>();

            userpower = _powerCheckProvider.CheckPower(power);
            sa        = _powerCheckProvider.CheckSAuser(empid);
            if (sa.EmpId != null)
            {
                _customerProvider.AddCustomer(cms);
                a = "添加成功";
            }
            else
            {
                if (userpower.Contains("404"))
                {
                    _customerProvider.AddCustomer(cms);
                    a = "添加成功";
                }
                else
                {
                    a = "权限不足";
                }
            }
            return(Json(a, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public IActionResult Post([FromBody] CustomerBaseDto dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = _provider.AddCustomer(dto);

            return(result == null?StatusCode(500, "A problem occurred while handling your request.")
                       : CreatedAtRoute("GetCustomer", new { id = result.CustomerId }, result));
        }
예제 #3
0
 public async Task <CustomerDto> AddCustomer(CustomerDto newCustomer)
 {
     if (newCustomer == null)
     {
         return(null);
     }
     else
     {
         newCustomer.CustomerTypeId = newCustomer.CustomerType.CustomerTypeId;
         Task <CustomerDto> customerDto;
         lock (_obj)
         {
             customerDto = _customerProvider.AddCustomer(newCustomer);
         }
         return(await customerDto);
     }
 }