usingOhMyGlobeProject.Models; | |
usingSystem; | |
usingSystem.Collections.Generic; | |
usingSystem.IO; | |
usingSystem.Linq; | |
usingSystem.Web; | |
usingSystem.Web.Mvc; | |
namespaceOhMyGlobeProject.Controllers | |
{ | |
publicclassGeoPostController : Controller | |
{ | |
privateApplicationDbContextdb=newApplicationDbContext(); | |
publicActionResultGetPost(intID) | |
{ | |
varmodel=db.GeoPosts.FirstOrDefault(x=>x.ID==ID); | |
returnJson(new { Data=model, JsonRequestBehavior=JsonRequestBehavior.AllowGet }); | |
} | |
[HttpPost] | |
publicActionResultCreatePost(GeoPostnewPost) | |
{ | |
stringmessage=""; | |
boolisSuccess=false; | |
try | |
{ | |
varfiles=Request.Files; | |
db.GeoPosts.Add(newPost); | |
foreach (variteminfiles) | |
{ | |
varpath=CommonLogic.UploadPhoto((HttpPostedFileBase)item); | |
if (!String.IsNullOrWhiteSpace(path)) | |
{ | |
db.GeoPostsImagePaths.Add(newGeoPostImagePaths { Post=newPost, FilePath=path }); | |
} | |
} | |
db.SaveChanges(); | |
isSuccess=true; | |
} | |
catch(Exceptionex) | |
{ | |
message=ex.Message; | |
} | |
returnJson(new{ isSuccess=isSuccess, message }); | |
} | |
publicActionResultGetPostComment(intGeoPost_ID) | |
{ | |
varmodel=db.GeoPosts.Where(x=>x.ID==GeoPost_ID).ToList(); | |
returnJson(new { Data=model, JsonRequestBehavior=JsonRequestBehavior.AllowGet }); | |
} | |
[HttpPost] | |
publicActionResultCreatePostComment(GeoPostCommentsnewPostComment) | |
{ | |
stringmessage=""; | |
boolisSuccess=false; | |
try | |
{ | |
db.GeoPostsComments.Add(newPostComment); | |
db.SaveChanges(); | |
isSuccess=true; | |
} | |
catch (Exceptionex) | |
{ | |
message=ex.Message; | |
} | |
returnJson(new { isSuccess=isSuccess, message }); | |
} | |
} | |
} |
Вчера наша команда получила очень неоднозначные отзывы от менторов. Сегодня мы решили прислушаться к сказанному. Работы много и очень разной, но желание завершить прототип придаёт сил.
SpaceApps is a NASA incubator innovation program.