public IActionResult UpdatePage(GetPageDetails form) { string res = ""; if (form.DefImage != null) { res = AddFile.AddImage(form.DefImage, form.Id); } var result = new List <String>(); if (form.Image != null) { result = AddFile.AddImages(form.Image, form.Id); } PageDetail det = new PageDetail(); det.Id = form.Id; det.Topic = form.Topic; det.SubTopic = form.SubTopic; det.Type = form.Type; det.Dis1 = form.Dis1; det.Dis2 = form.Dis2; det.Dis3 = form.Dis3; det.IsActive = true; det.District = form.District; det.Town = form.Town; det.Location = form.location; if (form.DefImage != null) { det.DefImage = res; } try { var im = _service.AddImageName(result, form.Id); var up = _service.UpdatePage(det); if (up && im) { return(Ok()); } return(BadRequest()); } catch { return(BadRequest()); } }
// [Produces("application/json")] // [Consumes("application/json")] public IActionResult Tests([FromForm] GetPageDetails form) { try { string res = ""; if (form.DefImage != null) { res = AddFile.AddImage(form.DefImage, form.Id); } var result = new List <String>(); if (form.Image != null) { result = AddFile.AddImages(form.Image, form.Id); } PageDetail det = new PageDetail(); det.Id = form.Id; det.Topic = form.Topic; det.SubTopic = form.SubTopic; det.Type = form.Type; det.Dis1 = form.Dis1; det.Dis2 = form.Dis2; det.Dis3 = form.Dis3; det.DefImage = res; det.UsersEmail = form.Author; det.District = form.District; det.Town = form.Town; det.Location = form.location; det.IsActive = true; if ((_service.AddPageDetails(det) && _service.AddImageName(result, form.Id))) { return(Ok(result)); } return(BadRequest()); } catch { return(BadRequest()); } }