Esempio n. 1
0
        /// <summary>
        ///     Better approach to save things into database(than db.SaveChanges()) for this controller.
        /// </summary>
        /// <param name="ViewStates">Say the view state, where it is calling from.</param>
        /// <param name="App">Your model information to send in email to developer when failed to save.</param>
        /// <returns>If successfully saved returns true or else false.</returns>
        private bool SaveDatabase(ViewStates view, IApp app = null)
        {
            // working those at HttpPost time.
            switch (view)
            {
            case ViewStates.Create:
                break;

            case ViewStates.Edit:
                break;

            case ViewStates.Delete:
                break;
            }
            if (app != null)
            {
                app.AppName = Logics.GetAllUpperCaseTitle(app.AppName);
            }
            var changes = db.SaveChanges(app);

            if (changes > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        //               ViewBag.Title;
        //ViewBag.Meta = "Tags , Mobile apps, apps review, apple apps, android apps,reviews, app review site, " +
        //ViewBag.Title = "Mobile Applications Tags";

        public ActionResult GetTagDetail(string id, int page = 1)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(HttpNotFound());
            }
            var tagname = Logics.GetAllUpperCaseTitle(id);

            ViewBag.Keywords = ViewBag.Meta;
            var cacheName = "Tags.GetTagDetail." + id;
            var apps      = _logics.GetViewableApps(db)
                            .Where(n => n.TagAppRelations.Any(tagRel => tagRel.Tag.TagDisplay == tagname))
                            .Include(n => n.User)
                            .OrderByDescending(n => n.AppID);
            int maxItems = (int)AppConfig.Setting.PageItems;

            var pageInfo = new PaginationInfo {
                ItemsInPage = maxItems,
                PageNumber  = page,
            };
            var appsForThisPage =
                apps.GetPageData(pageInfo, CacheNames.ProfilePaginationDataForSpecificProfile, true)
                .ToList();

            _logics.GetEmbedImagesWithApp(appsForThisPage, db, maxItems, GalleryCategoryIDs.SearchIcon);
            ViewBag.Apps = appsForThisPage;
            var eachUrl = ControllerUrl + "/" + id + "?page=@page";

            ViewBag.paginationHtml = new HtmlString(Pagination.GetList(pageInfo, eachUrl, "", maxNumbersOfPagesShow: MaxNumbersOfPagesShow));
            ViewBag.tagName        = tagname;
            ViewBag.breadcrumbs    = _logics.GetBredcrumbsBasedOnCurrentUrl();
            return(View());
        }
Esempio n. 3
0
        public static ApplicationUser GetUserFromViewModel(RegisterViewModel model)
        {
            var user = new ApplicationUser {
                UserName  = Logics.GetAllUpperCaseTitle(model.UserName),
                FirstName = Logics.GetAllUpperCaseTitle(model.FirstName),
                LastName  = Logics.GetAllUpperCaseTitle(model.LastName),
                Email     = model.Email,
                //DateOfBirth = model.DateOfBirth,
                CreatedDate    = DateTime.Now,
                EmailConfirmed = false,
                PhoneNumber    = model.Phone,
                //CountryID = model.CountryID,
                //CountryLanguageID = model.CountryLanguageID,
                //UserTimeZoneID = model.UserTimeZoneID,
                IsRegistrationComplete = false,
                GeneratedGuid          = Guid.NewGuid()
            };

            return(user);
        }
Esempio n. 4
0
        /// <summary>
        ///     Called specifically from Post save or edit save
        ///     not from AdditionNeccessaryFields
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="uploadGuid"></param>
        /// <param name="tagString">Given tag list as comma separated value.</param>
        private void ManageTagsInDatabase(long appId, Guid uploadGuid, string tagString)
        {
            new Thread(() => {
                if (!string.IsNullOrWhiteSpace(tagString))
                {
                    using (var db2 = new ReviewAppsEntities()) {
                        // remove any previous tag relation with this app.
                        // remove all previous tag relation-ship with this app.
                        db2.Database.ExecuteSqlCommand("DELETE FROM TagAppRelation WHERE AppID=@p0", appId);
                        var tagsList = tagString.Split(";,".ToCharArray());
                        foreach (var tag in tagsList)
                        {
                            string tagDisplay   = Logics.GetAllUpperCaseTitle(tag);
                            var tagFromDatabase = db2.Tags.FirstOrDefault(n => n.TagDisplay == tagDisplay);
                            if (tagFromDatabase == null)
                            {
                                // creating tag
                                // if tag not exist in the database then create one.
                                tagFromDatabase = new Tag {
                                    TagDisplay = Logics.GetAllUpperCaseTitle(tagDisplay)
                                };
                                db2.Tags.Add(tagFromDatabase);
                            }

                            //db2.SaveChanges(); //remove this for testing if works

                            // add tag relation with this app
                            var newTagRel = new TagAppRelation();
                            //newTagRel.TagID = tagFromDatabase.TagID; // may not need to bind the tags id because it will be done by EF
                            newTagRel.AppID = appId;
                            tagFromDatabase.TagAppRelations.Add(newTagRel);
                            db2.SaveChanges();
                        }
                    }
                }
            }).Start();
        }