public async Task <int> SaveIssueMember(int issueId, int userId, string relationShipType)
        {
            using (var db = new TeamEntitiesConn())
            {
                var re =
                    db.IssueMembers.FirstOrDefault(
                        s => s.IssueID == issueId && s.MemberID == userId && s.RelationType == relationShipType);
                if (re == null)
                {
                    re = new IssueMember
                    {
                        MemberID    = userId,
                        IssueID     = issueId,
                        CreatedByID = userId,
                        CreatedDate = DateTime.UtcNow
                    };
                    db.IssueMembers.Add(re);
                    await db.SaveChangesAsync();

                    return(1);
                }
                else
                {
                    db.IssueMembers.Remove(re);
                    await db.SaveChangesAsync();

                    return(0);
                }
            }
        }
Пример #2
0
 public async Task Delete(int id)
 {
     using (var db = new TeamEntitiesConn())
     {
         var c = db.Comments.FirstOrDefault(s => s.ID == id);
         if (c != null)
         {
             db.Comments.Remove(c);
             await db.SaveChangesAsync();
         }
     }
 }
 public List<CommentVM> GetComments(int issueId)
 {
     var db = new TeamEntitiesConn();
     return db.Comments.Where(s => s.IssueID == issueId)
         .Select(s => new CommentVM
         {
             ID = s.ID,
             CommentBody = s.CommentText,
             CreativeDate = s.CreatedDate,
             Author = new UserDto { EmailAddress = s.Author.EmailAddress, Name = s.Author.FirstName }
         }).ToList();
 }
        public async Task Delete(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var c = db.Comments.FirstOrDefault(s => s.ID == id);
                if (c != null)
                {
                    db.Comments.Remove(c);
                    await db.SaveChangesAsync();
                }

            }
        }
 public async Task<List<UserDto>> GetSubscribers(int teamId, NotificationTypeCode notificationType)
 {
     using (var db = new TeamEntitiesConn())
     {
         var notificationTypeCode = notificationType.ToString();
         return await db.UserNotificationSubscriptions.Where(s => s.NotificationType.Code == notificationTypeCode)
             .Select(x => new UserDto
             {
                 EmailAddress = x.User.EmailAddress,
                 Id = x.User.ID,
                 Name = x.User.FirstName
             }).ToListAsync();
     }
 }
Пример #6
0
 public async Task <List <UserDto> > GetSubscribers(int teamId, NotificationTypeCode notificationType)
 {
     using (var db = new TeamEntitiesConn())
     {
         var notificationTypeCode = notificationType.ToString();
         return(await db.UserNotificationSubscriptions.Where(s => s.NotificationType.Code == notificationTypeCode)
                .Select(x => new UserDto
         {
             EmailAddress = x.User.EmailAddress,
             Id = x.User.ID,
             Name = x.User.FirstName
         }).ToListAsync());
     }
 }
Пример #7
0
        public List <CommentVM> GetComments(int issueId)
        {
            var db = new TeamEntitiesConn();

            return(db.Comments.Where(s => s.IssueID == issueId)
                   .Select(s => new CommentVM
            {
                ID = s.ID,
                CommentBody = s.CommentText,
                CreativeDate = s.CreatedDate,
                Author = new UserDto {
                    EmailAddress = s.Author.EmailAddress, Name = s.Author.FirstName
                }
            }).ToList());
        }
 public int Save(CommentVM comment)
 {
     using (var db = new TeamEntitiesConn())
     {
         var commentEntity = new Comment();
         commentEntity.IssueID = comment.IssueId;
         commentEntity.CommentText = comment.CommentBody;
         commentEntity.CreatedDate = DateTime.Now;
         commentEntity.CreatedByID = comment.Author.Id;
         ;
         db.Comments.Add(commentEntity);
         db.SaveChanges();
         return commentEntity.ID;
     }
 }
Пример #9
0
 public int Save(CommentVM comment)
 {
     using (var db = new TeamEntitiesConn())
     {
         var commentEntity = new Comment();
         commentEntity.IssueID     = comment.IssueId;
         commentEntity.CommentText = comment.CommentBody;
         commentEntity.CreatedDate = DateTime.Now;
         commentEntity.CreatedByID = comment.Author.Id;
         ;
         db.Comments.Add(commentEntity);
         db.SaveChanges();
         return(commentEntity.ID);
     }
 }
        public IssueDetailVM GetIssue(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var issue = db.Issues.FirstOrDefault(s => s.ID == id);
                if (issue != null)
                {
                    var issueDto = new IssueDetailVM
                    {
                        ID          = issue.ID,
                        Title       = issue.Title,
                        Description = issue.Description ?? string.Empty,
                        Author      = new UserDto {
                            Id = issue.CreatedBy.ID, Name = issue.CreatedBy.FirstName
                        },
                        Project = new KeyValueItem {
                            Id = issue.Project.ID, Name = issue.Project.Name
                        },
                        TeamID = issue.TeamID,
                        Status = new KeyValueItem {
                            Id = issue.Category.ID, Name = issue.Status.Name
                        },
                        CreatedDate = issue.CreatedDate,
                        Category    = new KeyValueItem {
                            Id = issue.Category.ID, Name = issue.Category.Name
                        },
                        StatusGroupCode = issue.Status.StatusGroup.Code
                    };
                    if (issue.Priority != null)
                    {
                        issueDto.Priority = new KeyValueItem {
                            Id = issue.Priority.ID, Name = issue.Priority.Name
                        };
                    }


                    if (issue.ModifiedDate.HasValue && issue.ModifiedDate.Value > DateTime.MinValue && issue.ModifiedBy != null)
                    {
                        issueDto.LastModifiedDate = issue.ModifiedDate.Value.ToString("g");
                        issueDto.LastModifiedBy   = issue.ModifiedBy.FirstName;
                    }

                    return(issueDto);
                }
            }
            return(null);
        }
        public async Task Delete(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var c = new Comment {ID = id};
                db.Comments.Attach(c);
                db.Comments.Remove(c);
                await db.SaveChangesAsync();
                //var c = db.Comments.FirstOrDefault(s => s.ID == id);
                //if (c != null)
                //{
                //    db.Comments.Remove(c);
                //    await db.SaveChangesAsync();
                //}

            }
        }
 public CommentVM GetComment(int commentId)
 {
     using (var db = new TeamEntitiesConn())
     {
         var comment = db.Comments.FirstOrDefault(s => s.ID == commentId);
         if (comment != null)
         {
             return new CommentVM
             {
                 CommentBody = comment.CommentText,
                 CreativeDate = comment.CreatedDate,
                 Author =  new UserDto { EmailAddress = comment.Author.EmailAddress, Name = comment.Author.FirstName },
                 Issue =  new IssueVM {  Id = comment.Issue.ID, Title = comment.Issue.Title}
             };
         }
     }
     return null;
 }
Пример #13
0
        public async Task Delete(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var c = new Comment {
                    ID = id
                };
                db.Comments.Attach(c);
                db.Comments.Remove(c);
                await db.SaveChangesAsync();

                //var c = db.Comments.FirstOrDefault(s => s.ID == id);
                //if (c != null)
                //{
                //    db.Comments.Remove(c);
                //    await db.SaveChangesAsync();
                //}
            }
        }
        public List<ActivityDto> GetActivityItems(int count)
        {
            using (var db = new TeamEntitiesConn())
            {
               return db.Activities
                    .OrderByDescending(g=>g.CreatedDate)
                    .Take(count)
                    .Select(x => new ActivityDto
                {
                   ObjectId =  x.ObjectID,
                   CreatedTime = x.CreatedDate,
                   ObjectTite = x.ObjectTitle,
                        Actor = new UserDto {  Id = x.User.ID, Name = x.User.FirstName, EmailAddress = x.User.EmailAddress},
                   NewState = x.NewState,
                   ObjectType = x.ObjectType,
                   Description = x.ActivityDesc
                }).ToList();

            }
        }
        public ActivityDto GetActivityItem(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var x = db.Activities.FirstOrDefault(s=>s.ID==id);


                return new ActivityDto
                {
                    ObjectId = x.ObjectID,
                    CreatedTime = x.CreatedDate,
                    ObjectTite = x.ObjectTitle,
                    Actor = new UserDto {Id = x.User.ID, Name = x.User.FirstName, EmailAddress = x.User.EmailAddress},
                    NewState = x.NewState,
                    ObjectType = x.ObjectType,
                    Description = x.ActivityDesc
                };

            }
        }
        //var issueVM = new IssueVM { ID = bug.ID, Title = bug.Title, Description = bug.Description };
        //issueVM.OpenedBy = bug.CreatedBy.FirstName;
        //    issueVM.PriorityName = bug.PriorityName.Name;
        //    issueVM.StatusName = bug.StatusName.Name;
        //    issueVM.CategoryName = bug.CategoryName.Name;
        //    issueVM.Project = (bug.Project!=null?bug.Project.Name:"");
        //    issueVM.CreatedDate = bug.CreatedDate.ToShortDateString();
        public DashBoardItemSummaryVM GetDashboardSummaryVM(int teamId)
        {
            var vm = new DashBoardItemSummaryVM();
            using (var db = new TeamEntitiesConn())
            {
                var statusCounts = db.Issues
                    .Where(s => s.TeamID == teamId)
                    .GroupBy(d => d.Status, g => g.ID, (k, i) => new
                ItemCount
                    {
                        ItemId = k.ID,
                        ItemName = k.Name,
                        Count = i.Count()
                    }).ToList();

                vm.IssueCountsByStatus = statusCounts;
            }

            return vm;
        }
Пример #17
0
        public ActivityDto GetActivityItem(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var x = db.Activities.FirstOrDefault(s => s.ID == id);


                return(new ActivityDto
                {
                    ObjectId = x.ObjectID,
                    CreatedTime = x.CreatedDate,
                    ObjectTite = x.ObjectTitle,
                    Actor = new UserDto {
                        Id = x.User.ID, Name = x.User.FirstName, EmailAddress = x.User.EmailAddress
                    },
                    NewState = x.NewState,
                    ObjectType = x.ObjectType,
                    Description = x.ActivityDesc
                });
            }
        }
        //var issueVM = new IssueVM { ID = bug.ID, Title = bug.Title, Description = bug.Description };
        //issueVM.OpenedBy = bug.CreatedBy.FirstName;
        //    issueVM.PriorityName = bug.PriorityName.Name;
        //    issueVM.StatusName = bug.StatusName.Name;
        //    issueVM.CategoryName = bug.CategoryName.Name;
        //    issueVM.Project = (bug.Project!=null?bug.Project.Name:"");
        //    issueVM.CreatedDate = bug.CreatedDate.ToShortDateString();


        public DashBoardItemSummaryVM GetDashboardSummaryVM(int teamId)
        {
            var vm = new DashBoardItemSummaryVM();

            using (var db = new TeamEntitiesConn())
            {
                var statusCounts = db.Issues
                                   .Where(s => s.TeamID == teamId)
                                   .GroupBy(d => d.Status, g => g.ID, (k, i) => new
                                            ItemCount
                {
                    ItemId   = k.ID,
                    ItemName = k.Name,
                    Count    = i.Count()
                }).ToList();

                vm.IssueCountsByStatus = statusCounts;
            }

            return(vm);
        }
Пример #19
0
 public List <ActivityDto> GetActivityItems(int count)
 {
     using (var db = new TeamEntitiesConn())
     {
         return(db.Activities
                .OrderByDescending(g => g.CreatedDate)
                .Take(count)
                .Select(x => new ActivityDto
         {
             ObjectId = x.ObjectID,
             CreatedTime = x.CreatedDate,
             ObjectTite = x.ObjectTitle,
             Actor = new UserDto {
                 Id = x.User.ID, Name = x.User.FirstName, EmailAddress = x.User.EmailAddress
             },
             NewState = x.NewState,
             ObjectType = x.ObjectType,
             Description = x.ActivityDesc
         }).ToList());
     }
 }
Пример #20
0
 public CommentVM GetComment(int commentId)
 {
     using (var db = new TeamEntitiesConn())
     {
         var comment = db.Comments.FirstOrDefault(s => s.ID == commentId);
         if (comment != null)
         {
             return(new CommentVM
             {
                 CommentBody = comment.CommentText,
                 CreativeDate = comment.CreatedDate,
                 Author = new UserDto {
                     EmailAddress = comment.Author.EmailAddress, Name = comment.Author.FirstName
                 },
                 Issue = new IssueVM {
                     ID = comment.Issue.ID, Title = comment.Issue.Title
                 }
             });
         }
     }
     return(null);
 }
        public int Save(ActivityDto activity)
        {
            using (var db = new TeamEntitiesConn())
            {
                var a = new Activity
                {
                    OldState = activity.OldState,
                    NewState = activity.NewState,
                    ObjectID = activity.ObjectId,
                    ObjectType = activity.ObjectType,
                    ActivityDesc = activity.Description,
                    ObjectTitle = activity.ObjectTite,
                    CreatedByID = activity.Actor.Id,
                    TeamID = activity.TeamId,
                    CreatedDate = DateTime.Now
                };

                db.Activities.Add(a);
                db.SaveChanges();
                return a.ID;
            }
        }
Пример #22
0
        public int Save(ActivityDto activity)
        {
            using (var db = new TeamEntitiesConn())
            {
                var a = new Activity
                {
                    OldState     = activity.OldState,
                    NewState     = activity.NewState,
                    ObjectID     = activity.ObjectId,
                    ObjectType   = activity.ObjectType,
                    ActivityDesc = activity.Description,
                    ObjectTitle  = activity.ObjectTite,
                    CreatedByID  = activity.Actor.Id,
                    TeamID       = activity.TeamId,
                    CreatedDate  = DateTime.Now
                };

                db.Activities.Add(a);
                db.SaveChanges();
                return(a.ID);
            }
        }
 public IEnumerable <IssuesPerStatusGroup> GetIssuesGroupedByStatusGroup(int count)
 {
     using (var db = new TeamEntitiesConn())
     {
         return(db.Status.GroupBy(s => s.StatusGroup, s => s, (k, items) =>
                                  new IssuesPerStatusGroup
         {
             GroupName = k.Name,
             GroupCode = k.Code,
             Issues = items.SelectMany(d => d.Issues)
                      .Select(p => new IssueDetailVM
             {
                 ID = p.ID,
                 Title = p.Title,
                 Description = p.Description,
                 PriorityName = p.Priority.Name,
                 StatusName = p.Status.Name,
                 CategoryName = p.Category.Name,
                 Category = new KeyValueItem {
                     Id = p.Category.ID, Name = p.Category.Name
                 },
                 Priority = new KeyValueItem {
                     Id = p.Project.ID, Name = p.Priority.Name
                 },
                 Author = new UserDto {
                     Id = p.CreatedBy.ID, Name = p.CreatedBy.FirstName
                 },
                 Status = new KeyValueItem {
                     Id = p.Project.ID, Name = p.Status.Name
                 },
                 Project = new KeyValueItem {
                     Id = p.Project.ID, Name = p.Project.Name
                 },
                 CreatedDate = p.CreatedDate
             }).ToList()
         }).ToList());
     }
 }
        public IssueDetailVM GetIssue(int id)
        {
            using (var db = new TeamEntitiesConn())
            {
                var issue = db.Issues.FirstOrDefault(s => s.ID == id);
                if (issue != null)
                {
                    var issueDto = new IssueDetailVM
                    {
                        ID = issue.ID,
                        Title = issue.Title,
                        Description = issue.Description ?? string.Empty,
                        Author = new UserDto { Id = issue.CreatedBy.ID, Name = issue.CreatedBy.FirstName },
                        Project = new KeyValueItem { Id = issue.Project.ID, Name = issue.Project.Name },
                        TeamID = issue.TeamID,
                        Status = new KeyValueItem { Id = issue.Category.ID, Name = issue.Status.Name },
                        CreatedDate = issue.CreatedDate,
                        Category = new KeyValueItem { Id = issue.Category.ID, Name = issue.Category.Name },
                        StatusGroupCode = issue.Status.StatusGroup.Code

                    };
                    if (issue.Priority != null)
                    {
                        issueDto.Priority = new KeyValueItem {Id = issue.Priority.ID, Name = issue.Priority.Name};
                    }

                    if (issue.ModifiedDate.HasValue && issue.ModifiedDate.Value > DateTime.MinValue && issue.ModifiedBy != null)
                    {
                        issueDto.LastModifiedDate = issue.ModifiedDate.Value.ToString("g");
                        issueDto.LastModifiedBy = issue.ModifiedBy.FirstName;
                    }

                    return issueDto;
                }
            }
            return null;
        }
        public IEnumerable <IssueDetailVM> GetIssues(List <int> statusIds, int count)
        {
            using (var db = new TeamEntitiesConn())
            {
                return(db.Issues.AsNoTracking().Where(s => statusIds.Contains(s.StatusID))
                       .OrderByDescending(s => s.CreatedDate)
                       .Take(count)

                       .Select(s => new IssueDetailVM
                {
                    ID = s.ID,
                    Title = s.Title,
                    Description = s.Description,
                    PriorityName = s.Priority.Name,
                    StatusName = s.Status.Name,
                    CategoryName = s.Category.Name,
                    Category = new KeyValueItem {
                        Id = s.Category.ID, Name = s.Category.Name
                    },
                    Priority = new KeyValueItem {
                        Id = s.Project.ID, Name = s.Priority.Name
                    },
                    Author = new UserDto {
                        Id = s.CreatedBy.ID, Name = s.CreatedBy.FirstName
                    },
                    //  Project = s.Project.Name,
                    Status = new KeyValueItem {
                        Id = s.Project.ID, Name = s.Status.Name
                    },
                    Project = new KeyValueItem {
                        Id = s.Project.ID, Name = s.Project.Name
                    },
                    CreatedDate = s.CreatedDate
                })
                       .ToList());
            }
        }
Пример #26
0
 public Repositary()
 {
    db = new TeamEntitiesConn();
 }
        public int SaveIssue(CreateIssue issue)
        {
            Issue issueEntity = null;

            using (var db = new TeamEntitiesConn())
            {
                if (issue.ID > 0)
                {
                    issueEntity = db.Issues.FirstOrDefault(s => s.ID == issue.ID);
                    if (issueEntity == null)
                    {
                        return(0);
                    }
                }
                else
                {
                    issueEntity = new Issue();
                }
                issueEntity.Title       = issue.Title;
                issueEntity.Description = issue.Description;
                issueEntity.ProjectID   = issue.ProjectID;
                issueEntity.TeamID      = issue.TeamID;
                issueEntity.CategoryID  = issue.SelectedCategory;

                issueEntity.CreatedByID = issue.CreatedByID;
                issueEntity.Location    = issue.Iteration;
                issueEntity.StatusID    = issue.SelectedStatus;
                issueEntity.PriorityID  = issue.SelectedPriority;

                if (issueEntity.CategoryID == 0)
                {
                    issueEntity.CategoryID = db.Categories.FirstOrDefault().ID;
                }
                if (issueEntity.StatusID == 0)
                {
                    var status = db.Status.FirstOrDefault(s => s.Code == "New");
                    issueEntity.StatusID = status.ID;
                }
                if (issueEntity.PriorityID == null || issueEntity.PriorityID.Value == 0)
                {
                    var priority = db.Priorities.FirstOrDefault(s => s.Code == "Normal");
                    issueEntity.PriorityID = priority.ID;
                }

                if (issue.ID == 0)
                {
                    issueEntity.CreatedDate = DateTime.UtcNow;
                    issueEntity.Active      = true;
                    db.Issues.Add(issueEntity);
                }
                else
                {
                    issueEntity.ModifiedDate = DateTime.Now;
                    issueEntity.ModifiedByID = issue.CreatedByID;

                    db.Entry(issueEntity).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(issueEntity.ID);
            }
        }
 public ProjectRepository()
 {
     db = new TeamEntitiesConn();
 }
 public TeamRepository()
 {
     db = new TeamEntitiesConn();
 }
 public AccountRepository()
 {
     db = new TeamEntitiesConn();
 }
        public async Task<int> SaveIssueMember(int issueId, int userId, string relationShipType)
        {
            using (var db = new TeamEntitiesConn())
            {
                var re =
                    db.IssueMembers.FirstOrDefault(
                        s => s.IssueID == issueId && s.MemberID == userId && s.RelationType == relationShipType);
                if (re == null)
                {
                    re = new IssueMember
                    {
                        MemberID = userId,
                        IssueID = issueId,
                        CreatedByID = userId,
                        CreatedDate = DateTime.UtcNow
                    };
                    db.IssueMembers.Add(re);
                    await db.SaveChangesAsync();
                    return 1;

                }
                else
                {
                    db.IssueMembers.Remove(re);
                    await db.SaveChangesAsync();
                    return 0;
                }
            }
        }
        public IEnumerable<IssuesPerStatusGroup> GetIssuesGroupedByStatusGroup(int count)
        {
            using (var db = new TeamEntitiesConn())
            {

                return db.Status.GroupBy(s => s.StatusGroup, s => s, (k, items) =>
                    new IssuesPerStatusGroup
                    {
                        GroupName = k.Name,
                        GroupCode = k.Code,
                        Issues = items.SelectMany(d => d.Issues)
                            .Select(p => new IssueDetailVM
                            {
                                Id = p.ID,
                                Title = p.Title,
                                Description = p.Description,
                                PriorityName = p.Priority.Name,
                                StatusName = p.Status.Name,
                                CategoryName = p.Category.Name,
                                Category = new KeyValueItem { Id = p.Category.ID, Name = p.Category.Name },
                                Priority = new KeyValueItem { Id = p.Project.ID, Name = p.Priority.Name },
                                Author = new UserDto { Id = p.CreatedBy.ID, Name = p.CreatedBy.FirstName },
                                Status = new KeyValueItem { Id = p.Project.ID, Name = p.Status.Name },
                                Project = new KeyValueItem { Id = p.Project.ID, Name = p.Project.Name },
                                CreatedDate = p.CreatedDate
                            }).ToList()
                    }).ToList();
            }

        }
 public ProjectRepository()
 {
     db = new TeamEntitiesConn();
 }
Пример #34
0
 public TeamRepository()
 {
     db = new TeamEntitiesConn();
 }
Пример #35
0
 public Repositary()
 {
     db = new TeamEntitiesConn();
 }
 public EmailTemplateRepository()
 {
     db = new TeamEntitiesConn();
 }
        public IEnumerable<IssueDetailVM> GetIssues(List<int> statusIds, int count)
        {
            using (var db = new TeamEntitiesConn())
            {

                return db.Issues.AsNoTracking().Where(s => statusIds.Contains(s.StatusID))
                    .OrderByDescending(s => s.CreatedDate)
                    .Take(count)

                    .Select(s => new IssueDetailVM
                    {
                        Id = s.ID,
                        Title = s.Title,
                        Description = s.Description,
                        PriorityName = s.Priority.Name,
                        StatusName = s.Status.Name,
                        CategoryName = s.Category.Name,
                        Category = new KeyValueItem { Id = s.Category.ID, Name = s.Category.Name },
                        Priority = new KeyValueItem { Id = s.Project.ID, Name = s.Priority.Name },
                        Author = new UserDto { Id = s.CreatedBy.ID, Name = s.CreatedBy.FirstName },
                        //  Project = s.Project.Name,
                        Status = new KeyValueItem { Id = s.Project.ID, Name = s.Status.Name },
                        Project = new KeyValueItem { Id = s.Project.ID, Name = s.Project.Name },
                        CreatedDate = s.CreatedDate
                    })
                    .ToList();
            }
        }
Пример #38
0
 public AccountRepository()
 {
     db = new TeamEntitiesConn();
 }
        public int SaveIssue(CreateIssue issue)
        {
            Issue issueEntity = null;
            using (var db = new TeamEntitiesConn())
            {

                if (issue.Id > 0)
                {
                    issueEntity = db.Issues.FirstOrDefault(s => s.ID == issue.Id);
                    if (issueEntity == null)
                    {
                        return 0;
                    }
                }
                else
                {
                    issueEntity = new Issue();
                }
                issueEntity.Title = issue.Title;
                issueEntity.Description = issue.Description;
                issueEntity.ProjectID = issue.ProjectID;
                issueEntity.TeamID = issue.TeamID;
                issueEntity.CategoryID = issue.SelectedCategory;

                issueEntity.CreatedByID = issue.CreatedByID;
                issueEntity.Location = issue.Iteration;
                issueEntity.StatusID = issue.SelectedStatus;
                issueEntity.PriorityID = issue.SelectedPriority;

                if (issueEntity.CategoryID == 0)
                {
                    issueEntity.CategoryID = db.Categories.FirstOrDefault().ID;
                }
                if (issueEntity.StatusID == 0)
                {

                    var status = db.Status.FirstOrDefault(s => s.Code == "New");
                    issueEntity.StatusID = status.ID;
                }
                if (issueEntity.PriorityID == null || issueEntity.PriorityID.Value == 0)
                {
                    var priority = db.Priorities.FirstOrDefault(s => s.Code == "Normal");
                    issueEntity.PriorityID = priority.ID;
                }

                if (issue.Id == 0)
                {
                    issueEntity.CreatedDate = DateTime.UtcNow;
                    issueEntity.Active = true;
                    db.Issues.Add(issueEntity);
                }
                else
                {
                    issueEntity.ModifiedDate = DateTime.Now;
                    issueEntity.ModifiedByID = issue.CreatedByID;

                    db.Entry(issueEntity).State = EntityState.Modified;

                }

                db.SaveChanges();
                return issueEntity.ID;
            }
        }
Пример #40
0
 public EmailTemplateRepository()
 {
     db = new TeamEntitiesConn();
 }