Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult AddNewZone(InterestAreaVm model)
        {
            if (ModelState.IsValid)
            {
                var custome = _customerService.GetCustomerbyName(User.Identity.Name);
                if (custome != null)
                {
                    var area = Mapper.Map <InterestArea>(model);
                    area.Id         = Guid.NewGuid();
                    area.CustomerId = custome.Id;
                    var r = _customerService.AddArea(area);
                    return(Json(r, JsonRequestBehavior.AllowGet));
                }
            }

            var validation = ValidationViewModel();

            return(Json(validation, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <JsonResult> AddNewZone(InterestAreaVm model)
        {
            if (ModelState.IsValid)
            {
                var customer = await _customerService.GetCustomerByNameAsync(User.Identity.Name).ConfigureAwait(false);

                if (customer != null)
                {
                    var area = Mapper.Map <InterestArea>(model);
                    area.Id         = Guid.NewGuid();
                    area.CustomerId = customer.Id;
                    var r = _customerService.AddArea(area);
                    return(Json(r, JsonRequestBehavior.AllowGet));
                }
            }

            var validation = ValidationViewModel();

            return(Json(validation, JsonRequestBehavior.AllowGet));
        }