Guest User

Guest User

  • Tech Writer
  • 611
  • 127.8k

Error in code a code.

Mar 24 2020 1:03 AM
public ActionResult AddFavourite(int? Favid, string Type)
{
FavouriteMang obj_favouriteman = new FavouriteMang();
tblSequence obj_tblSequence = new tblSequence();
int MaxOrderNumber = _db.tblSequences.Count();
if (Type == "Team")
{
var tblteam = _db.tblTeams.Where(u => u.Team_Id == Favid).FirstOrDefault();
tblteam.IsFavourite = true;
}
else if (Type == "League")
{
// FavouriteMang obj_favouriteman = new FavouriteMang();
try
{
if (Type == "Team")
{
var tblteam = _db.tblTeams.Where(u => u.Team_Id == Favid).FirstOrDefault();
tblteam.IsFavourite = true;
}
else if (Type == "League")
{
var tblleague = _db.tblLeagues.Where(u => u.LeagueId == Favid).FirstOrDefault();
tblleague.IsFavourite = true;
}
else if (Type == "Club")
{
var tblclub = _db.tblClubs.Where(u => u.ClubId == Favid).FirstOrDefault();
tblclub.IsFavourite = true;
}
_db.SaveChanges();
}
catch (Exception)
{
throw;
}
_db.SaveChanges();
obj_tblSequence.FavType = Type;
obj_tblSequence.IdFav = Favid;
obj_tblSequence.OrderNumber = MaxOrderNumber + 1;
_db.tblSequences.Add(obj_tblSequence);
_db.SaveChanges();
return View();
}
}
}
}
 
 C# '': not all code paths return a value- this error show.
This is my code . Face a problem plzz solve error. () 

Answers (2)