예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        public ActionResult EnableUserBlock(UserBlockViewModel model)
        {
            var user = db.Users.Find(model.UserId);

            if (user != null)
            {
                //same user
                user.IsBlocked       = false;
                user.BlockedbyUserId = 0;
                user.BlockingReason  = "";
                db.Entry(user).State = EntityState.Modified;
                if (SaveDatabase(ViewStates.EditPost, user))
                {
                    var currentUserName = UserManager.GetCurrentUser().DisplayName;

                    var mailBody = MailHtml.ReleasedFromBlockEmailHtml(user, currentUserName, true);

                    AppVar.Mailer.Send(user.Email, "You have been re-enabled.", mailBody, "Enabled");

                    return(RedirectToAction("Index"));
                }
                AppVar.SetErrorStatus(ViewBag, EditedError);
                return(View(user));
            }
            AppVar.SetErrorStatus(ViewBag, EditedError);
            return(View(user));
        }
예제 #8
0
        public ActionResult UserBlock(UserBlockViewModel model)
        {
            var user = db.Users.Find(model.UserId);

            if (user != null)
            {
                //same user
                user.IsBlocked       = true;
                user.BlockedbyUserId = UserManager.GetLoggedUserId();
                db.Entry(user).State = EntityState.Modified;
                if (SaveDatabase(ViewStates.EditPost, user))
                {
                    var currentUserName = UserManager.GetCurrentUser().DisplayName;

                    var mailBody = MailHtml.BlockEmailHtml(user, model.Reason, currentUserName);

                    AppVar.Mailer.Send(user.Email, "You have been blocked.", mailBody, "Blocking");

                    return(RedirectToAction("Index"));
                }
                AppVar.SetErrorStatus(ViewBag, EditedError);
                return(View(user));
            }
            AppVar.SetErrorStatus(ViewBag, EditedError);
            return(View("_404"));
        }
        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 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));
        }
예제 #11
0
 public ActionResult CleanSystem(string clean)
 {
     if (!string.IsNullOrEmpty(clean) && clean.Equals("Clean"))
     {
         var algorithm = new Logics();
         ViewBag.message = "Every thing is removed successfully.";
         AppVar.SetErrorStatus("Sorry ! Some went wrong in the server. Please get in touch with developer.");
     }
     return(View());
 }
예제 #12
0
        public ActionResult Edit(FeedbackCategory feedbackCategory)
        {
            GetDropDowns();
            if (ModelState.IsValid)
            {
                db.Entry(feedbackCategory).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            AppVar.SetErrorStatus(ViewBag);
            return(View(feedbackCategory));
        }
예제 #13
0
        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));
        }
예제 #14
0
        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));
        }
예제 #15
0
        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));
        }
예제 #16
0
 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));
 }
예제 #17
0
        public ActionResult DeleteConfirmed(byte id)
        {
            var platform = db.Platforms.Find(id);
            var viewOf   = ViewTapping(ViewStates.DeletePost, platform);

            db.Platforms.Remove(platform);
            var state = SaveDatabase(ViewStates.Delete, platform);

            if (!state)
            {
                AppVar.SetErrorStatus(ViewBag, _deletedError); // Failed to Save
                return(View(platform));
            }

            return(RedirectToAction("Index"));
        }
예제 #18
0
        public ActionResult DeleteConfirmed(int id)
        {
            var  subject = db.Subjects.Find(id);
            bool viewOf  = ViewTapping(ViewStates.DeletePost, subject);

            db.Subjects.Remove(subject);
            bool state = SaveDatabase(ViewStates.Delete, subject);

            if (!state)
            {
                AppVar.SetErrorStatus(ViewBag, DeletedError);                 // Failed to Save
                return(View(subject));
            }

            return(RedirectToAction("Index"));
        }
예제 #19
0
        public ActionResult DeleteConfirmed(int id)
        {
            var galleryCategory = db.GalleryCategories.Find(id);
            var viewOf          = ViewTapping(ViewStates.DeletePost, galleryCategory);

            db.GalleryCategories.Remove(galleryCategory);
            var state = SaveDatabase(ViewStates.Delete, galleryCategory);

            if (!state)
            {
                AppVar.SetErrorStatus(ViewBag, _deletedError); // Failed to Save
                return(View(galleryCategory));
            }

            return(RedirectToAction("Index"));
        }
예제 #20
0
        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));
        }
예제 #21
0
        public ActionResult Edit(Feedback feedback)
        {
            GetDropDowns();
            if (ModelState.IsValid)
            {
                db.Entry(feedback).State = EntityState.Modified;
                feedback.IsSolved        = true;
                feedback.IsUnSolved      = false;
                feedback.IsViewed        = true;
                feedback.IsInProcess     = false;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            AppVar.SetErrorStatus(ViewBag);
            return(View(feedback));
        }
        public ActionResult DeleteConfirmed(long id)
        {
            var featuredImage =
                db.FeaturedImages.Include(n => n.App).Include(n => n.User).FirstOrDefault(n => n.FeaturedImageID == id);
            var viewOf = ViewTapping(ViewStates.DeletePost, featuredImage);

            db.FeaturedImages.Remove(featuredImage);
            var state = SaveDatabase(ViewStates.Delete, featuredImage);

            if (!state)
            {
                AppVar.SetErrorStatus(ViewBag, _deletedError); // Failed to Save
                return(View(featuredImage));
            }

            return(RedirectToAction("Index"));
        }
예제 #23
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            var gallery = db.Galleries.Find(id);
            var viewOf  = ViewTapping(ViewStates.DeletePost, gallery);

            db.Galleries.Remove(gallery);

            var state = SaveDatabase(ViewStates.Delete, gallery);

            if (!state)
            {
                AppVar.SetErrorStatus(ViewBag, _deletedError); // Failed to Save

                return(View(gallery));
            }
            Statics.UProcessorAdvertiseImages.RemoveTempImage(gallery, false);

            return(RedirectToAction("Index"));
        }
예제 #24
0
        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));
        }
예제 #25
0
        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));
        }
예제 #26
0
        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));
        }
예제 #27
0
        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));
        }