public Tuple <bool, string> AddOrUpdate(Slider slider, StateOperation stateOperation, bool saveChange) { try { if (stateOperation == StateOperation.درج) { _sliderRepository.Add(slider); } else { _sliderRepository.Update(slider); } if (saveChange) { _unitOfWork.SaveChanges(); } return(new Tuple <bool, string>(true, "عملیات ثبت شد")); } catch (Exception ex) { return(new Tuple <bool, string>(false, "خطا در انجام عملیات")); } }
public IActionResult Create(SliderUploadVM SliderUploadVM, IFormFile file) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (file == null || file.Length == 0) { return(BadRequest("Your file was not valid!")); } using (Stream stream = file.OpenReadStream()) { using (BinaryReader br = new BinaryReader(stream)) { var fileContent = br.ReadBytes((int)file.Length); SliderUploadVM.Image = SaveFileHelper.SaveFileToDisk(_env, fileContent, file.FileName, file.ContentType); } } Slider _newSlider = Mapper.Map <Slider>(SliderUploadVM); _sliderRepository.Add(_newSlider); _sliderRepository.SaveChanges(); CreatedAtRouteResult result = CreatedAtRoute("GetCategory", new { controller = "Categories", id = SliderUploadVM.Id }, SliderUploadVM); return(result); }
public async Task <IActionResult> SliderCreate(Slider entity, IFormFile file) { if (ModelState.IsValid) { if (file != null) { var extention = Path.GetExtension(file.FileName); var imgName = string.Format($"{file.FileName}_{DateTime.Now.Ticks}{extention}"); var img = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\Img", imgName); using (var stream = new FileStream(img, FileMode.Create)) { await file.CopyToAsync(stream); entity.ImageURL = imgName; } } _sliderRepository.Add(entity); _sliderRepository.Save(); return(RedirectToAction("SliderList", "Admin")); } return(View(entity)); }
public ResultMessage <Slider> Add(Slider data) { data.isActive = true; return(_sliderRepository.Add(data)); }
public Slider Add(Slider model) { return(_sliderRepository.Add(model)); }
public void CreateSlider(Slider slider) { sliderRepository.Add(slider); }
public void Save(Sliders slider) { _sliderRepository.Add(slider); _unitOfWork.Complete(); }
public void CreateSlider(Slider Slider) { SliderRepository.Add(Slider); }
public async Task <bool> AddSliderPhoto(ZabotaSlider model) { await _sliderRepository.Add(model); return(true); }