public JsonResult AddGallery(AddGalleryViewModel viewModel) { try { _galleryService.Create(ModelMapper.ConvertToModel(viewModel)); return(Json(true)); } catch (Exception) { return(Json(false)); } }
public HttpResponseMessage NewGalleriy([FromBody] string name) { if (string.IsNullOrEmpty(name)) { return(Request.CreateResponse(HttpStatusCode.NotAcceptable)); } var galleriy = _galleryService.Create(); galleriy.Name = name; galleriy.IsDeleted = false; _galleryService.Add(galleriy); _unitOfWork.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); return(response); }