public ActionResult Add([ModelBinder(typeof(DevExpressEditorsBinder))]  LayoutModel layoutModel)
        {
            var _HiddenUid = Request["_HiddenUid"];

            layoutModel._HiddenUid = _HiddenUid;

            layoutModel._UserId = (int)Session["userId"];

            layoutService = new LayoutService();


            if (ModelState.IsValid)
            {
                if (layoutModel._HiddenUid != "")
                {
                    layoutModel.Data = System.IO.File.ReadAllBytes(LayoutUploadControlHelper.GetFilePath(layoutModel._HiddenUid));
                }

                layoutService.Add(layoutModel);
                layoutModel = layoutService.GetNewModel();
            }
            else
            {
                string message = GetErrorModel();

                throw new Exception(string.Format("[VALIDATION] {0}", message));
            }


            layoutModel._FormMode = Models.FormModeEnum.New;


            return(PartialView(VIEW_FORM_PARTIAL, layoutModel));
        }
        public ActionResult Add([ModelBinder(typeof(DevExpressEditorsBinder))]  RoleModel roleModel)
        {
            roleModel._UserId = (int)Session["userId"];

            roleService = new RoleService();

            fillCheckValue(roleModel);

            if (ModelState.IsValid)
            {
                roleService.Add(roleModel);
                roleModel = roleService.GetNewModel();
            }
            else
            {
                string message = GetErrorModel();

                throw new Exception(string.Format("[VALIDATION] {0}", message));
            }


            roleModel._FormMode = Models.FormModeEnum.New;

            return(PartialView(VIEW_FORM_PARTIAL, roleModel));
        }
Пример #3
0
        public void Create()
        {
            Console.Clear();
            var master = new MasterDto();

            Output.WriteLine(ConsoleColor.Cyan, "Create master");

            try
            {
                Console.Write("First name: ");
                master.FirstName = Console.ReadLine();
                Console.Write("Surname: ");
                master.Surname = Console.ReadLine();
                Console.Write($"Phone: ");
                master.Phone = Console.ReadLine();
                Console.Write($"Passport id: ");
                master.PassportId = Console.ReadLine();

                _masterService.Add(master);
                Output.WriteLine(ConsoleColor.Green, "Creation was successful");
                Console.ReadKey();
                Program.NavigateTo <MasterPage>();
            }
            catch (ArgumentNullException e)
            {
                Output.WriteLine(ConsoleColor.Red, e.Message);
            }
        }
Пример #4
0
        public IActionResult Create(MasterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var masterDto = _mapper.Map <MasterDto>(model);

            _masterService.Add(masterDto);
            return(Redirect(nameof(Index)));
        }
Пример #5
0
        public ActionResult Create([FromBody] MasterDto master)
        {
            try
            {
                _masterService.Add(master);
            }
            catch (Exception)
            {
                return(BadRequest());
            }

            return(Ok());
        }
Пример #6
0
        public async Task <ActionResult> PostMaster(MasterViewModel masterViewModel)
        {
            try
            {
                MasterDTO masterDTO = _mapper.Map <MasterDTO>(masterViewModel);

                _masterService.Add(masterDTO);
                return(Ok());
            }
            catch
            {
                return(StatusCode(500));
            }
        }
Пример #7
0
        public ActionResult RegisterMaster(UserViewModel user)
        {
            if (!ModelState.IsValid)
            {
                return(View(user));
            }

            var userToAdd = Mapper.Map <UserViewModel, User>(user);

            _userService.Create(userToAdd);

            var masterToAdd = Mapper.Map <UserViewModel, Master>(user);

            using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
            {
                masterToAdd.Photo = binaryReader.ReadBytes(Request.Files[0].ContentLength);
            }

            _masterService.Add(masterToAdd, user.Login);

            return(RedirectToAction("Main", "Home"));
        }