예제 #1
0
        public JsonResult CreateLocation(string LocatonName, int channelId)
        {
            if (_locationSvc.AddLocation(LocatonName, channelId) == true)
            {
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }

            return(Json("Failure", JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public async Task <IActionResult> AddLocation(NewLocationModel model)
        {
            var location = new Location
            {
                LocationName    = model.LocationName,
                LocationAddress = model.LocationAddress,
                LocationMapUrl  = model.LocationMap
            };
            await _locationService.AddLocation(location);

            return(RedirectToAction("Index", "Location"));
        }
        public async Task <IActionResult> AddLocation(LocationCreationDto location)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            var locationAdd = _mapper.Map <Location>(location);

            if (location == null)
            {
                return(UnprocessableEntity());
            }
            if (await _location.AddLocation(locationAdd))
            {
                return(CreatedAtRoute("GetCategory", new { id = locationAdd.LocationID }, _mapper.Map <LocationReturnDto>(locationAdd)));
            }
            return(BadRequest());
        }
예제 #4
0
        public async Task <IActionResult> Register(Register register)
        {
            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            var location = _mapper.Map <Location>(register);

            if (await _location.AddLocation(location))
            {
                var user = _mapper.Map <User>(register);
                user.LocationID = location.LocationID;
                var result = await _userManager.CreateAsync(user, register.Password);

                if (result.Succeeded)
                {
                    return(StatusCode(201));
                }
                var error = result.Errors.Select(x => x.Description);
                return(Conflict(error));
            }
            return(BadRequest());
        }
예제 #5
0
파일: BLocation.cs 프로젝트: giagiigi/MYDZ
 /// <summary>
 /// 添加一行数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 bool AddLocation(Location model)
 {
     return(SetLocation.AddLocation(model));
 }