示例#1
0
        public IActionResult Edit(int id, CameraFormModel cameraModel)
        {
            var updated = this.cameras.Edit(
                id,
                cameraModel.Make,
                cameraModel.Model,
                cameraModel.Price,
                cameraModel.Quantity,
                cameraModel.MinShutterSpeed,
                cameraModel.MaxShutterSpeed,
                cameraModel.MinISO,
                cameraModel.MaxISO,
                cameraModel.IsFullFrame,
                cameraModel.VideoResolution,
                cameraModel.LightMetering,
                cameraModel.Description,
                cameraModel.ImageUrl,
                this.userManager.GetUserId(User));

            if (!updated)
            {
                return(NotFound());
            }

            return(RedirectToAction(nameof(All)));
        }
示例#2
0
        public IActionResult Add(CameraFormModel cameraModel)
        {
            if (cameraModel.LightMeterings == null || !cameraModel.LightMeterings.Any())
            {
                ModelState.AddModelError(nameof(cameraModel.LightMeterings), "Please select at least one light metering.");
            }

            if (!ModelState.IsValid)
            {
                return(this.View(cameraModel));
            }

            this.cameras.Create(
                cameraModel.Make,
                cameraModel.Model,
                cameraModel.Price,
                cameraModel.Quantity,
                cameraModel.MinShutterSpeed,
                cameraModel.MaxShutterSpeed,
                cameraModel.MinISO,
                cameraModel.MaxISO,
                cameraModel.IsFullFrame,
                cameraModel.VideoResolution,
                cameraModel.LightMeterings,
                cameraModel.Description,
                cameraModel.ImageUrl,
                this.userManager.GetUserId(User));

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
示例#3
0
        public IActionResult Add(CameraFormModel cameraModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(cameraModel));
            }

            this.cameras.Create(
                cameraModel.Make,
                cameraModel.Model,
                cameraModel.Price,
                cameraModel.Quantity,
                cameraModel.MinShutterSpeed,
                cameraModel.MaxShutterSpeed,
                cameraModel.MinISO,
                cameraModel.MaxISO,
                cameraModel.IsFullFrame,
                cameraModel.VideoResolution,
                cameraModel.LightMetering,
                cameraModel.Description,
                cameraModel.ImageUrl,
                this.userManager.GetUserId(User));

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
        public IActionResult Add(CameraFormModel camera)
        {
            if (!ModelState.IsValid)
            {
                return(View(camera));
            }

            this.cameras.Add(
                camera.Make,
                camera.Model,
                camera.Price,
                camera.Quantity,
                camera.MinShutterSpeed,
                camera.MaxShutterSpeed,
                camera.MinIso,
                camera.MaxIso,
                camera.IsFullFrame,
                camera.VideoResolution,
                camera.LightMeterings,
                camera.Description,
                camera.ImageUrl,
                this.userManager.GetUserId(HttpContext.User));

            this.GenerateOperationMessage(string.Format(CameraBazaarConstants.Message.SuccessAddCamera, camera.Make, camera.Model), Alert.Success);

            return(RedirectToAction(nameof(All)));
        }
        public IActionResult Add(CameraFormModel cameraModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(cameraModel));
            }

            return(null);
        }
示例#6
0
        public IActionResult Edit(int id, CameraFormModel cameraModel)
        {
            //// id of the user
            //string userId = "sdfsdfsdfsd";
            //// is user, who try to edit is same as the currently loged user ?
            //var allowed = (userId == this.userManager.GetUserId(this.User));
            //if (!allowed)
            //{
            //    return this.Unauthorized();
            //}

            // is this camera created by this.User ?
            var cameraExists = this.cameras.Exists(id, this.userManager.GetUserId(this.User));

            if (!cameraExists)
            {
                return(this.NotFound());
            }

            if (cameraModel.LightMeterings == null || !cameraModel.LightMeterings.Any())
            {
                ModelState.AddModelError(nameof(cameraModel.LightMeterings), "Please select at least one light metering.");
            }

            if (!ModelState.IsValid)
            {
                return(this.View(cameraModel));
            }

            var updated = this.cameras.Edit(
                id,
                cameraModel.Make,
                cameraModel.Model,
                cameraModel.Price,
                cameraModel.Quantity,
                cameraModel.MinShutterSpeed,
                cameraModel.MaxShutterSpeed,
                cameraModel.MinISO,
                cameraModel.MaxISO,
                cameraModel.IsFullFrame,
                cameraModel.VideoResolution,
                cameraModel.LightMeterings,
                cameraModel.Description,
                cameraModel.ImageUrl);

            if (!updated)
            {
                return(this.NotFound());
            }

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
        public IActionResult Add()
        {
            var cameraModel = new CameraFormModel();

            var lightMeteringModels = new List <CkeckboxLightMeteringModel>();

            foreach (LightMetering lightMetering in Enum.GetValues(typeof(LightMetering)))
            {
                lightMeteringModels.Add(new CkeckboxLightMeteringModel
                {
                    LightMetering = lightMetering,
                    IsCheck       = false
                });
            }

            cameraModel.CheckboxLightMeteringModels = lightMeteringModels;

            return(View(cameraModel));
        }
 public IActionResult Edit(int id, CameraFormModel cameraModel)
 {
     return(RedirectToAction(nameof(Details), new { id = id }));
 }