public JsonResult Insert(InformationContentCRUDModel informationContentCRUDModel) { Response response = new Response(); try { informationContentProvider = new InformationContentProvider(); AppUserModel appUserModel = SessionExtension.GetSessionUser(HttpContext.Session); InformationApiContentCRUDModel apiContentCRUDModel = new InformationApiContentCRUDModel() { CategoryId = informationContentCRUDModel.CategoryId, Explanation = informationContentCRUDModel.Explanation, Title = informationContentCRUDModel.Title, LikeCount = 0, AuthorId = appUserModel.AppUser.AppUserId, TokenKey = appUserModel.TokenKey }; if (informationContentCRUDModel.InformationImage != null) { byte[] data; using (var ms = new MemoryStream()) { informationContentCRUDModel.InformationImage.CopyTo(ms); apiContentCRUDModel.PostImagePath = Path.GetExtension(informationContentCRUDModel.InformationImage.FileName); data = ms.ToArray(); } var fileContent = new ByteArrayContent(data); apiContentCRUDModel.ImageArrayList = fileContent; informationContentProvider.InsertInformationContent(apiContentCRUDModel); } response = new Response() { Message = "success", Status = true, }; } catch (Exception ex) { response = new Response() { Message = "Failed", Status = false }; } return(Json(response)); }
public IActionResult Insert() { InformationContentCRUDModel informationContentCRUDModel = new InformationContentCRUDModel(); categoryProvider = new CategoryProvider(); InfrastructureModel <List <Category> > infrastructerCategoryList = categoryProvider.GetCategoryList(SessionExtension.GetSessionUserTokeyKey(HttpContext.Session)); informationContentCRUDModel.CategoryList = new SelectList(infrastructerCategoryList.ResultModel, "CategoryId", "Name"); return(View(informationContentCRUDModel)); }