public bool Insert(Common.RoutingType routingType, int userId, Category category = null, Content content = null, Author author = null, Tag tag = null) { try { var defineRouting = new DefineRouting(); switch (routingType) { case Common.RoutingType.Category: { defineRouting.Controller = Constants.CategoryController; defineRouting.Action = Constants.CategoryAction; defineRouting.FriendlyUrlLv2 = NormalizeFriendlyUrl(routingType, ExtensionMethod.GenerateSlug(category.Title)); defineRouting.EntityId = category.CategoryId; break; } case Common.RoutingType.Content: { defineRouting.Controller = Constants.ContentController; defineRouting.Action = Constants.ContentAction; defineRouting.FriendlyUrlLv2 = NormalizeFriendlyUrl(routingType, ExtensionMethod.GenerateSlug(content.Title)); defineRouting.EntityId = content.ContentId; break; } case Common.RoutingType.Author: { defineRouting.Controller = Constants.AuthorController; defineRouting.Action = Constants.AuthorAction; defineRouting.FriendlyUrlLv2 = NormalizeFriendlyUrl(routingType, ExtensionMethod.GenerateSlug(string.Format("{0} {1}", author.FirstName.Trim(), author.LastName.Trim()))); defineRouting.EntityId = author.AuthorId; break; } case Common.RoutingType.Tag: { defineRouting.Controller = Constants.TagController; defineRouting.Action = Constants.TagAction; defineRouting.FriendlyUrlLv2 = NormalizeFriendlyUrl(routingType, ExtensionMethod.GenerateSlug(tag.TagName)); defineRouting.EntityId = tag.TagId; break; } } defineRouting.FriendlyUrlLv1 = routingType.ToString().ToLower(); defineRouting.CreatedUserId = defineRouting.UpdatedUserId = userId; _routingRepository.Create(defineRouting); return(true); } catch { return(false); } }
public bool Update(DefineRouting defineRouting) { try { _routingRepository.Update(defineRouting); return(true); } catch (Exception) { return(false); } }