Exemple #1
0
        public async Task <ActionResult> New()
        {
            var user = await GetCurrentUserAsync();

            var userstate = await GetUserDetails(user);

            if (userstate == 2)
            {
                TipAndLetterEdit tagandstatus = new TipAndLetterEdit();
                tagandstatus.Tags = db.Tags.ToList();
                var tags = tagandstatus.Tags.Count();
                tagandstatus.TipStatuss = db.TipStatuss.ToList();
                var tipstatus = tagandstatus.TipStatuss.Count();
                if (tags == 0)
                {
                    return(RedirectToAction("New", "Tag"));
                }
                else if (tipstatus == 0)
                {
                    return(RedirectToAction("New", "TipStatus"));
                }
                else
                {
                    return(View(tagandstatus));
                }
            }
            else
            {
                return(RedirectToAction("index", "Home"));
            }
        }
Exemple #2
0
        public async Task <ActionResult> Edit(int id)
        {
            var user = await GetCurrentUserAsync();

            var userstate = await GetUserDetails(user);

            if (userstate == 2)
            {
                TipAndLetterEdit htl = new TipAndLetterEdit();

                htl.TipAndLetter =
                    db.TipAndLetters
                    .Include(t => t.TipStatus)
                    .Include(t => t.Tag)
                    .SingleOrDefault(t => t.TipAndLetterID == id);

                htl.TipStatuss = db.TipStatuss.ToList();
                htl.Tags       = db.Tags.ToList();

                if (htl.TipAndLetter != null)
                {
                    return(View(htl));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(RedirectToAction("index", "Home"));
            }
        }