Exemplo n.º 1
0
        public ActionResult CreateOnlyEp(string epName, string totalTrack)
        {
            logics         = new GeneralLogics();
            businessLogics = new BusinessLogics();

            List <string> inputStrings = new List <string> {
                epName, totalTrack
            };

            string userEmail = Session["LoginEmail"].ToString();

            //string userEmail = "*****@*****.**";
            if (userEmail != null)
            {
                if (!logics.ContainsAnyNullorWhiteSpace(inputStrings))
                {
                    if (logics.ContainsOnlyDigits(totalTrack))
                    {
                        if (Convert.ToInt32(totalTrack) > 7)
                        {
                            ViewBag.ErrorMsg = "An Ep can be created with 7 or less amount of tracks";
                        }
                        else
                        {
                            var result = businessLogics.CreateNewEp(userEmail, epName, Convert.ToInt32(totalTrack));

                            if (result == 0)
                            {
                                ViewBag.ErrorMsg = "No Account is associated with the email address from which user is trying to create the Ep.";
                            }

                            if (result == 1)
                            {
                                return(RedirectToAction("Index", "UserProfile"));
                            }

                            if (result == 2)
                            {
                                ViewBag.ErrorMsg = "No purchase left to create an music Ep";
                            }

                            if (result == 3 || result == 4)
                            {
                                ViewBag.ErrorMsg = "Internal error occured while creating the Ep";
                            }
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMsg = "Track number field must contains only number. Invalid input given";
                    }
                }
                else
                {
                    ViewBag.ErrorMsg = "No fields should be left empty";
                }
            }
            else
            {
                return(RedirectToAction("Logout", "Authentication"));
            }
            return(View("AddorEditEp"));
        }