Initial commit
This commit is contained in:
18
Server/Core/Repositories/MessageRepository.cs
Normal file
18
Server/Core/Repositories/MessageRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DotNetNuke.Common;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using Bring2mind.InMemoriam.Core.Models.Messages;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
public partial class MessageRepository : ServiceLocator<IMessageRepository, MessageRepository>, IMessageRepository
|
||||
{
|
||||
}
|
||||
public partial interface IMessageRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
84
Server/Core/Repositories/MessageRepository_Core.cs
Normal file
84
Server/Core/Repositories/MessageRepository_Core.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DotNetNuke.Common;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using Bring2mind.InMemoriam.Core.Models.Messages;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
|
||||
public partial class MessageRepository : ServiceLocator<IMessageRepository, MessageRepository>, IMessageRepository
|
||||
{
|
||||
protected override Func<IMessageRepository> GetFactory()
|
||||
{
|
||||
return () => new MessageRepository();
|
||||
}
|
||||
public IEnumerable<Message> GetMessages(int moduleId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
return rep.Get(moduleId);
|
||||
}
|
||||
}
|
||||
public Message GetMessage(int moduleId, int messageId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
return rep.GetById(messageId, moduleId);
|
||||
}
|
||||
}
|
||||
public Message AddMessage(Message message)
|
||||
{
|
||||
Requires.NotNull(message);
|
||||
Requires.PropertyNotNegative(message, "ModuleId");
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
rep.Insert(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
public void DeleteMessage(Message message)
|
||||
{
|
||||
Requires.NotNull(message);
|
||||
Requires.PropertyNotNegative(message, "MessageId");
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
rep.Delete(message);
|
||||
}
|
||||
}
|
||||
public void DeleteMessage(int moduleId, int messageId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
rep.Delete("WHERE ModuleId = @0 AND MessageId = @1", moduleId, messageId);
|
||||
}
|
||||
}
|
||||
public void UpdateMessage(Message message)
|
||||
{
|
||||
Requires.NotNull(message);
|
||||
Requires.PropertyNotNegative(message, "MessageId");
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Message>();
|
||||
rep.Update(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial interface IMessageRepository
|
||||
{
|
||||
IEnumerable<Message> GetMessages(int moduleId);
|
||||
Message GetMessage(int moduleId, int messageId);
|
||||
Message AddMessage(Message message);
|
||||
void DeleteMessage(Message message);
|
||||
void DeleteMessage(int moduleId, int messageId);
|
||||
void UpdateMessage(Message message);
|
||||
}
|
||||
}
|
||||
|
||||
26
Server/Core/Repositories/PictureRepository.cs
Normal file
26
Server/Core/Repositories/PictureRepository.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Bring2mind.InMemoriam.Core.Models.Pictures;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
public partial class PictureRepository : ServiceLocator<IPictureRepository, PictureRepository>, IPictureRepository
|
||||
{
|
||||
public IEnumerable<Picture> GetPictures(int moduleId, int userId, string sortBy, string sortOrder)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Picture>();
|
||||
var sql = userId == -1 ? "WHERE ModuleId=@0 AND Visibility=0" : "WHERE ModuleId=@0 AND (CreatedByUserID=@1 OR Visibility<2)";
|
||||
sql += " ORDER BY " + sortBy + " " + sortOrder;
|
||||
return rep.Find(sql, moduleId, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial interface IPictureRepository
|
||||
{
|
||||
IEnumerable<Picture> GetPictures(int moduleId, int userId, string sortBy, string sortOrder);
|
||||
}
|
||||
}
|
||||
|
||||
90
Server/Core/Repositories/PictureRepository_Core.cs
Normal file
90
Server/Core/Repositories/PictureRepository_Core.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DotNetNuke.Common;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using Bring2mind.InMemoriam.Core.Models.Pictures;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
|
||||
public partial class PictureRepository : ServiceLocator<IPictureRepository, PictureRepository>, IPictureRepository
|
||||
{
|
||||
protected override Func<IPictureRepository> GetFactory()
|
||||
{
|
||||
return () => new PictureRepository();
|
||||
}
|
||||
public IEnumerable<Picture> GetPictures(int moduleId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Picture>();
|
||||
return rep.Get(moduleId);
|
||||
}
|
||||
}
|
||||
public Picture GetPicture(int moduleId, int pictureId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Picture>();
|
||||
return rep.GetById(pictureId, moduleId);
|
||||
}
|
||||
}
|
||||
public PictureBase AddPicture(PictureBase picture, int userId)
|
||||
{
|
||||
Requires.NotNull(picture);
|
||||
Requires.PropertyNotNegative(picture, "ModuleId");
|
||||
picture.CreatedByUserID = userId;
|
||||
picture.CreatedOnDate = DateTime.Now;
|
||||
picture.LastModifiedByUserID = userId;
|
||||
picture.LastModifiedOnDate = DateTime.Now;
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<PictureBase>();
|
||||
rep.Insert(picture);
|
||||
}
|
||||
return picture;
|
||||
}
|
||||
public void DeletePicture(PictureBase picture)
|
||||
{
|
||||
Requires.NotNull(picture);
|
||||
Requires.PropertyNotNegative(picture, "PictureId");
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<PictureBase>();
|
||||
rep.Delete(picture);
|
||||
}
|
||||
}
|
||||
public void DeletePicture(int moduleId, int pictureId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<PictureBase>();
|
||||
rep.Delete("WHERE ModuleId = @0 AND PictureId = @1", moduleId, pictureId);
|
||||
}
|
||||
}
|
||||
public void UpdatePicture(PictureBase picture, int userId)
|
||||
{
|
||||
Requires.NotNull(picture);
|
||||
Requires.PropertyNotNegative(picture, "PictureId");
|
||||
picture.LastModifiedByUserID = userId;
|
||||
picture.LastModifiedOnDate = DateTime.Now;
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<PictureBase>();
|
||||
rep.Update(picture);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial interface IPictureRepository
|
||||
{
|
||||
IEnumerable<Picture> GetPictures(int moduleId);
|
||||
Picture GetPicture(int moduleId, int pictureId);
|
||||
PictureBase AddPicture(PictureBase picture, int userId);
|
||||
void DeletePicture(PictureBase picture);
|
||||
void DeletePicture(int moduleId, int pictureId);
|
||||
void UpdatePicture(PictureBase picture, int userId);
|
||||
}
|
||||
}
|
||||
|
||||
18
Server/Core/Repositories/StoryRepository.cs
Normal file
18
Server/Core/Repositories/StoryRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DotNetNuke.Common;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using Bring2mind.InMemoriam.Core.Models.Stories;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
public partial class StoryRepository : ServiceLocator<IStoryRepository, StoryRepository>, IStoryRepository
|
||||
{
|
||||
}
|
||||
public partial interface IStoryRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
90
Server/Core/Repositories/StoryRepository_Core.cs
Normal file
90
Server/Core/Repositories/StoryRepository_Core.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DotNetNuke.Common;
|
||||
using DotNetNuke.Data;
|
||||
using DotNetNuke.Framework;
|
||||
using Bring2mind.InMemoriam.Core.Models.Stories;
|
||||
|
||||
namespace Bring2mind.InMemoriam.Core.Repositories
|
||||
{
|
||||
|
||||
public partial class StoryRepository : ServiceLocator<IStoryRepository, StoryRepository>, IStoryRepository
|
||||
{
|
||||
protected override Func<IStoryRepository> GetFactory()
|
||||
{
|
||||
return () => new StoryRepository();
|
||||
}
|
||||
public IEnumerable<Story> GetStories(int moduleId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Story>();
|
||||
return rep.Get(moduleId);
|
||||
}
|
||||
}
|
||||
public Story GetStory(int moduleId, int storyId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<Story>();
|
||||
return rep.GetById(storyId, moduleId);
|
||||
}
|
||||
}
|
||||
public StoryBase AddStory(StoryBase story, int userId)
|
||||
{
|
||||
Requires.NotNull(story);
|
||||
Requires.PropertyNotNegative(story, "ModuleId");
|
||||
story.CreatedByUserID = userId;
|
||||
story.CreatedOnDate = DateTime.Now;
|
||||
story.LastModifiedByUserID = userId;
|
||||
story.LastModifiedOnDate = DateTime.Now;
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<StoryBase>();
|
||||
rep.Insert(story);
|
||||
}
|
||||
return story;
|
||||
}
|
||||
public void DeleteStory(StoryBase story)
|
||||
{
|
||||
Requires.NotNull(story);
|
||||
Requires.PropertyNotNegative(story, "StoryId");
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<StoryBase>();
|
||||
rep.Delete(story);
|
||||
}
|
||||
}
|
||||
public void DeleteStory(int moduleId, int storyId)
|
||||
{
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<StoryBase>();
|
||||
rep.Delete("WHERE ModuleId = @0 AND StoryId = @1", moduleId, storyId);
|
||||
}
|
||||
}
|
||||
public void UpdateStory(StoryBase story, int userId)
|
||||
{
|
||||
Requires.NotNull(story);
|
||||
Requires.PropertyNotNegative(story, "StoryId");
|
||||
story.LastModifiedByUserID = userId;
|
||||
story.LastModifiedOnDate = DateTime.Now;
|
||||
using (var context = DataContext.Instance())
|
||||
{
|
||||
var rep = context.GetRepository<StoryBase>();
|
||||
rep.Update(story);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial interface IStoryRepository
|
||||
{
|
||||
IEnumerable<Story> GetStories(int moduleId);
|
||||
Story GetStory(int moduleId, int storyId);
|
||||
StoryBase AddStory(StoryBase story, int userId);
|
||||
void DeleteStory(StoryBase story);
|
||||
void DeleteStory(int moduleId, int storyId);
|
||||
void UpdateStory(StoryBase story, int userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user