Пример #1
0
        public IActionResult add(CareerDto model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _careerService.save(model);
                    AlertHelper.setMessage(this, "Career saved successfully.", messageType.success);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }

            return(View(model));
        }
        public IActionResult add(CareerDto model, IFormFile file = null)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        string fileName = model.title;
                        model.image_name = _fileHelper.saveImageAndGetFileName(file, fileName);
                    }
                    _careerService.save(model);
                    AlertHelper.setMessage(this, "Career saved successfully.", messageType.success);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }

            return(View(model));
        }