public async Task <IActionResult> AddWorkArea(WorkAreaAddViewModel model, IFormFile pic)
        {
            if (ModelState.IsValid)
            {
                if (pic != null)
                {
                    var extension = Path.GetExtension(pic.FileName);
                    var name      = _categoryService.GetById(model.CategoryId).Url + extension;
                    var path      = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/img/workarea-cover/" + name);
                    using var stream = new FileStream(path, FileMode.Create);
                    await pic.CopyToAsync(stream);

                    model.Picture = name;
                }

                var workArea = new WokrArea()
                {
                    Desciption = model.Description.Replace("&nbsp;", " "),
                    Picture    = model.Picture,
                    CategoryId = model.CategoryId
                };

                _workAreaService.Create(workArea);
                return(RedirectToAction("Index", "WorkArea", new { area = "Admin" }));
            }

            return(View(model));
        }
Esempio n. 2
0
 public void Update(WokrArea entity)
 {
     _workArea.Update(entity);
 }
Esempio n. 3
0
 public void Delete(WokrArea entity)
 {
     _workArea.Delete(entity);
 }
Esempio n. 4
0
 public void Create(WokrArea entity)
 {
     _workArea.Create(entity);
 }