public ActionResult Edit(FeaturedImage featuredImage) { var viewOf = ViewTapping(ViewStates.EditPost, featuredImage); if (ModelState.IsValid) { featuredImage.UserID = User.GetUserID(); db.Entry(featuredImage).State = EntityState.Modified; var state = SaveDatabase(ViewStates.Edit, featuredImage); if (state) { AppVar.SetSavedStatus(ViewBag, _editedSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to Save } return(RedirectToAction("Index")); } GetDropDowns(featuredImage); AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to save return(View(featuredImage)); }
public ActionResult Edit(App app) { var viewOf = ViewTapping(ViewStates.EditPost, app); var oldApp = _logics.GetEditingApp(app.AppID, db); app.CreatedDate = oldApp.CreatedDate; app.Url = oldApp.Url; if (ModelState.IsValid) { AddNecessaryWhenModified(app); db.Entry(app).State = EntityState.Modified; var state = SaveDatabase(ViewStates.Edit, app); if (state) { ManageTagsInDatabase(app.AppID, app.UploadGuid, app.Tags); _logics.RemoveCachingApp(app.AppID); AppVar.SetSavedStatus(ViewBag, EditSuccessFully(app.AppName, app.IsPublished)); // Saved Successfully. return(Redirect(app.GetAbsoluteUrl())); } } GetDropDowns(app); AppVar.SetErrorStatus(ViewBag, EditedError); // Failed to save return(View(app)); }
public ActionResult Create(FeaturedImage featuredImage) { var viewOf = ViewTapping(ViewStates.CreatePost, featuredImage); GetDropDowns(featuredImage); if (db.FeaturedImages.Any(n => n.AppID == featuredImage.AppID)) { AppVar.SetErrorStatus(ViewBag, "This app is already exist. Can't save."); // Saved Successfully. return(View(featuredImage)); } featuredImage.UserID = User.GetUserID(); if (ModelState.IsValid) { db.FeaturedImages.Add(featuredImage); var state = SaveDatabase(ViewStates.Create, featuredImage); if (state) { AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to save } return(View(featuredImage)); } AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to Save return(View(featuredImage)); }
public ActionResult Create(Gallery gallery) { var viewOf = ViewTapping(ViewStates.CreatePost, gallery); if (gallery.File != null) { gallery.Extension = UploadProcessor.GetExtension(gallery.File); } GetDropDowns(gallery); if (ModelState.IsValid) { gallery.GalleryID = Guid.NewGuid(); gallery.UploadGuid = gallery.GalleryID; db.Galleries.Add(gallery); var state = SaveDatabase(ViewStates.Create, gallery); DoUpload(gallery); if (state) { AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to save } return(View(gallery)); } AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to Save return(View(gallery)); }
public ActionResult Edit(Subject subject) { bool viewOf = ViewTapping(ViewStates.EditPostBefore, subject); if (ModelState.IsValid) { db.Entry(subject).State = EntityState.Modified; bool state = SaveDatabase(ViewStates.Edit, subject); if (state) { AppVar.SetSavedStatus(ViewBag, EditedSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, EditedError); // Failed to Save } viewOf = ViewTapping(ViewStates.EditPostAfter, subject, state); return(RedirectToAction("Index")); } viewOf = ViewTapping(ViewStates.EditPostAfter, subject, false); if (DropDownDynamic == false) { GetDropDowns(subject); // Generating drop downs } AppVar.SetErrorStatus(ViewBag, EditedError); // record not valid for save return(View(subject)); }
public ActionResult Edit(Gallery gallery) { var viewOf = ViewTapping(ViewStates.EditPost, gallery); if (gallery.File != null) { gallery.Extension = UploadProcessor.GetExtension(gallery.File); } if (ModelState.IsValid) { db.Entry(gallery).State = EntityState.Modified; var state = SaveDatabase(ViewStates.Edit, gallery); DoUpload(gallery); if (state) { AppVar.SetSavedStatus(ViewBag, _editedSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to Save } return(RedirectToAction("Index")); } GetDropDowns(gallery); AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to save return(View(gallery)); }
public ActionResult Create(Subject subject) { bool viewOf = ViewTapping(ViewStates.CreatePostBefore, subject); if (DropDownDynamic == false) { GetDropDowns(subject); } if (ModelState.IsValid) { db.Subjects.Add(subject); bool state = SaveDatabase(ViewStates.Create, subject); if (state) { AppVar.SetSavedStatus(ViewBag, CreatedSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, CreatedError); // Failed to save } viewOf = ViewTapping(ViewStates.CreatePostAfter, subject, state); return(View(subject)); } viewOf = ViewTapping(ViewStates.CreatePostAfter, subject, false); AppVar.SetErrorStatus(ViewBag, CreatedError); // record is not valid for creation return(View(subject)); }
public async Task <ActionResult> Reply(Feedback feedback, string Status) { var viewOf = ViewTapping(ViewStates.EditPostBefore, feedback); if (ModelState.IsValid) { // set status SetStatus(ref feedback, Status); db.Entry(feedback).State = EntityState.Modified; var state = SaveDatabase(ViewStates.Edit, feedback); if (state) { AppVar.SetSavedStatus(ViewBag, EditedSaved); // Saved Successfully. // send email SendEmail(feedback); } else { AppVar.SetErrorStatus(ViewBag, EditedError); // Failed to Save } viewOf = ViewTapping(ViewStates.EditPostAfter, feedback, state); return(RedirectToAction("Index")); } viewOf = ViewTapping(ViewStates.EditPostAfter, feedback, false); AppVar.SetErrorStatus(ViewBag, EditedError); // record not valid for save return(View(feedback)); }
public async Task <ActionResult> Post(App app) { var viewOf = ViewTapping(ViewStates.CreatePost, app); var currentApp = db.Apps.FirstOrDefault(n => n.UploadGuid == app.UploadGuid); GetDropDowns(app); if (currentApp != null) { // already saved.. // then don't save it anymore. app.UploadGuid = Guid.NewGuid(); // new post can be made ModelState.Clear(); return(View(app)); } AddingNeccessaryWhilePosting(app); if (ModelState.IsValid) { db.Apps.Add(app); var state = SaveDatabase(ViewStates.Create, app); if (state) { ManageTagsInDatabase(app.AppID, app.UploadGuid, app.Tags); RemoveTempUploadAndDraftFromRelatedApp(app.UploadGuid); AppVar.SetSavedStatus(ViewBag, PostedSuccessFully(app.AppName, app.IsPublished)); // Saved Successfully. app.UploadGuid = Guid.NewGuid(); // new post can be made //app.AppName = app.AppName + " 2"; var userEmail = User.GetUser().Email; var title = "'" + app.AppName + "' is created successfully. "; var body = "'" + app.AppName + "' is created successfully. Available at : " + app.GetAbsoluteUrl() + " <br> <br> Your app will be on home after 1 day. <br> Thank you."; if (!app.IsPublished) { title = "[Unpublished] " + title; body = "Your app is created successfully. However still not published. Please check the policies when you post the app or edit the app."; } AppVar.Mailer.Send(userEmail, title, body); ModelState.Clear(); return(View(app)); } } // if you are here that means you have done the uploads // no need to give upload options anymore. ViewBag.UploadDontNeed = true; var errorMessage = PostedFailed(app.AppName); AppVar.SetErrorStatus(ViewBag, errorMessage); // Failed to Save // ModelState.FirstOrDefault().Value.Errors. AppVar.Mailer.NotifyDeveloper(errorMessage, "Following error : ", entityObject: app, modelStateDictionary: ModelState); return(View(app)); }
public ActionResult Index(CoreSetting coreSetting, string tab) { ViewBag.tab = tab; if (ModelState.IsValid) { _db.Entry(coreSetting).State = EntityState.Modified; _db.SaveChanges(); AppConfig.RefreshSetting(); AppVar.SetSavedStatus(ViewBag); } AppVar.SetErrorStatus(ViewBag); return(View(coreSetting)); }
public ActionResult Create(FeedbackCategory feedbackCategory) { GetDropDowns(); if (ModelState.IsValid) { db.FeedbackCategories.Add(feedbackCategory); db.SaveChanges(); AppVar.SetSavedStatus(ViewBag); return(View(feedbackCategory)); } AppVar.SetErrorStatus(ViewBag); return(View(feedbackCategory)); }
public ActionResult Add(NavigationItem navigationItem) { AddMenuName(navigationItem.NavigationID); if (ModelState.IsValid) { HasDropDownAttr(navigationItem); db.NavigationItems.Add(navigationItem); AppVar.SetSavedStatus(ViewBag); db.SaveChanges(); AppConfig.Caches.RemoveAllFromCache(); return(View(navigationItem)); } AppVar.SetErrorStatus(ViewBag); return(View(navigationItem)); }
public ActionResult Moderate(AppModerateViewModel model) { App app; ApplicationUser developerUser; bool isFeaturedPreviously; if (!GetTempData(out app, out developerUser, out isFeaturedPreviously)) { // if app not found return(RedirectToAction("Index")); } SetTempData(app, developerUser, isFeaturedPreviously); model.App = app; if (app != null) { ViewBag.user = developerUser; if (app.IsBlocked != model.IsBlocked) { // needs to update if (model.IsBlocked) { ModerationLogics.BlockApp(model.AppId, true, db); } else { ModerationLogics.UnBlockApp(model.AppId, true, db); } } if (isFeaturedPreviously != model.IsFeatured) { // needs to update ModerationLogics.AppFeatured(model.AppId, model.IsFeatured, true, db); } var statusMessage = "You have successfully moderated '" + app.AppName + "' app."; if (!string.IsNullOrWhiteSpace(model.Message)) { SendEmailToAppDeveloper(developerUser, model); statusMessage += " An email is also sent!"; } AppVar.SetSavedStatus(ViewBag, statusMessage); return(View(model)); } AppVar.SetErrorStatus(ViewBag, "Sorry last transaction has been failed."); return(View(model)); }
public ActionResult ContactUs(Feedback feedback) { ViewBag.FeedbackCateoryID = new SelectList(db.FeedbackCategories.ToList(), "FeedbackCategoryID", "Category"); AppVar.GetTitlePageMeta(ViewBag, "Contact Us", null, "Contact Us - " + AppVar.Name, "Contact Us, Feedback about " + AppVar.Name); if (ModelState.IsValid) { db.Entry(feedback).State = EntityState.Added; db.SaveChanges(); AppVar.SetSavedStatus(ViewBag); //send a email. AppVar.Mailer.NotifyAdmin("A feedback has been added by " + feedback.Email, "Please check your feedback inbox. Feedback :<br>" + feedback.Message); return(View(feedback)); } AppVar.SetErrorStatus(ViewBag); return(View(feedback)); }
public async Task <ViewResult> ContactUs(Feedback feedback) { AppVar.GetTitlePageMeta(ViewBag, "Contact Us", null, "Contact Us - " + AppVar.Name, "Contact Us, Feedback about " + AppVar.Name); var user = UserManager.GetCurrentUser(); var oneHourBefore = DateTime.Now.AddHours(-1); var isReportedBefore = db.Feedbacks.Any(n => n.Username == user.UserName && n.PostedDate >= oneHourBefore); if (isReportedBefore) { return(View("Later")); } if (ModelState.IsValid) { feedback.PostedDate = DateTime.Now; feedback.Username = user.UserName; feedback.Name = user.DisplayName; db.Entry(feedback).State = EntityState.Added; db.SaveChanges(); AppVar.SetSavedStatus(ViewBag); //send a email. var body = EntityToString.Get(feedback); AppVar.Mailer.NotifyAdmin("A feedback has been added by " + feedback.Email, "Please check your feedback inbox.<br><br> Feedback :<br><q>" + feedback.Message + "</q><br>" + body); return(View("Done")); } ViewBag.FeedbackCateoryID = new SelectList( db.FeedbackCategories.Where( n => !(n.FeedbackCategoryID == FeedbackCategoryIDs.MobileAppReport || n.FeedbackCategoryID == FeedbackCategoryIDs.ReviewReport)).ToList(), "FeedbackCategoryID", "Category"); AppVar.SetErrorStatus(ViewBag); return(View(feedback)); }
public ActionResult Create(Platform platform) { var viewOf = ViewTapping(ViewStates.CreatePost, platform); GetDropDowns(platform); if (ModelState.IsValid) { db.Platforms.Add(platform); var state = SaveDatabase(ViewStates.Create, platform); if (state) { AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to save } return(View(platform)); } AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to Save return(View(platform)); }
public ActionResult Create(GalleryCategory galleryCategory) { var viewOf = ViewTapping(ViewStates.CreatePost, galleryCategory); GetDropDowns(galleryCategory); if (ModelState.IsValid) { db.GalleryCategories.Add(galleryCategory); var state = SaveDatabase(ViewStates.Create, galleryCategory); if (state) { AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to save } return(View(galleryCategory)); } AppVar.SetErrorStatus(ViewBag, _createdError); // Failed to Save return(View(galleryCategory)); }
public ActionResult Edit(Category category) { var viewOf = ViewTapping(ViewStates.EditPost, category); if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; var state = SaveDatabase(ViewStates.Edit, category); if (state) { AppVar.SetSavedStatus(ViewBag, _editedSaved); // Saved Successfully. } else { AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to Save } return(RedirectToAction("Index")); } GetDropDowns(category); AppVar.SetErrorStatus(ViewBag, _editedError); // Failed to save return(View(category)); }
public ActionResult Write(Review review) { var viewOf = ViewTapping(ViewStates.CreatePost, review); //GetDropDowns(review); AddNecessaryFields(review); ModelState.Remove("CreatedDate"); review.CreatedDate = DateTime.Now; if (ModelState.IsValid) { db.Reviews.Add(review); var state = SaveDatabase(ViewStates.Create, review); if (state) { _logics.AfterReviewIsSavedFixRatingNReviewCountInApp(review, true, db); _logics.ForceAppReviewToLoad(review.AppID); AppVar.SetSavedStatus(ViewBag, _createdSaved); // Saved Successfully. } return(Json(new { isDone = true, msg = "Successful." }, JsonRequestBehavior.AllowGet)); // return true; } return(Json(new { isDone = false, msg = "failed." }, JsonRequestBehavior.AllowGet)); // return true; }