Example #1
0
        public string getUpdateTeamName(Team teamName)
        {
            try
            {
                using (var entities = new WorkBountyDBEntities())
                {
                    var checkTeamName = entities.Teams.Where(x => x.TeamName == teamName.TeamName).FirstOrDefault();

                    if (checkTeamName == null)
                    {
                        var getTeamName = entities.Teams.Where(x => x.TeamUserInfoID == teamName.TeamUserInfoID).ToList();
                        getTeamName.ForEach(a =>
                        {
                            a.TeamName = teamName.TeamName;
                        });
                        entities.SaveChanges();
                        return("Success");
                    }
                    else
                    {
                        return("Error");
                    }
                }
            }
            catch (Exception)
            {
                return("Error");
            }
        }
 public string ApplyReward(Rewards id)
 {
     try
     {
         using (WorkBountyDBEntities entities = new WorkBountyDBEntities())
         {
             entities.Configuration.ValidateOnSaveEnabled = false;
             string   remarks = id.Remarks.ToString();
             Workitem remark  = new Workitem()
             {
                 WorkitemID = id.WorkItemID, Remarks = id.Remarks
             };
             entities.Workitems.Attach(remark);
             entities.Entry(remark).Property(u => u.Remarks).IsModified = true;
             entities.SaveChanges();
         }
         List <WorkItemAssignment> checkUploadedWorkitem = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).ToList();
         foreach (var data in checkUploadedWorkitem)
         {
             WorkItemAssignment item = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).FirstOrDefault();
             item.IsRewarded = true;
             entity.SaveChanges();
         }
         return("Success");
     }
     catch (Exception)
     {
         return("Error");
     }
 }
        public string EditWorkitem(Workitem id)
        {
            try
            {
                using (var entities = new WorkBountyDBEntities())
                {
                    var getWorkitemData = entities.Workitems.Where(x => x.WorkitemID == id.WorkitemID).ToList();
                    getWorkitemData.ForEach(a =>
                    {
                        if (id.Amount != null)
                        {
                            a.Amount = id.Amount;
                        }
                        a.ModifyBy = id.ModifyBy;
                        if (id.ModifyDateTime != null)
                        {
                            a.ModifyDateTime = id.ModifyDateTime;
                        }
                        a.PublishedTo = id.PublishedTo;
                        if (id.Summary != null)
                        {
                            a.Summary = id.Summary;
                        }
                        if (id.Title != null)
                        {
                            a.Title = id.Title;
                        }
                        if (id.ProposedReward != "undefined")
                        {
                            a.ProposedReward = id.ProposedReward;
                        }
                    }

                                            );
                    WorkitemStatu workitemstatusData = new WorkitemStatu();
                    string        statusDescription  = "Update";
                    workitemstatusData.StatusDescription = statusDescription;
                    workitemstatusData.WorkitemID        = id.WorkitemID;
                    entities.WorkitemStatus.Add(workitemstatusData);
                    entities.SaveChanges();
                    WorkitemHistory workitemHistoryData = new WorkitemHistory();
                    workitemHistoryData.WorkitemID      = id.WorkitemID;
                    workitemHistoryData.UpdatedBy       = id.ModifyBy;
                    workitemHistoryData.UpdatedDateTIme = DateTime.Now;
                    var getWorkitemStatusID = entities.WorkitemStatus.Where(s => s.WorkitemID == id.WorkitemID).Select(s => s.WorkitemStatusID).FirstOrDefault();
                    workitemHistoryData.WorkitemStatusID = getWorkitemStatusID;
                    entities.WorkitemHistories.Add(workitemHistoryData);
                    entities.SaveChanges();
                }

                return("Success");
            }
            catch (Exception)
            {
                return("Error");
            }
        }
 public string ApplyReward(Rewards id)
 {
     try
     {
         using (WorkBountyDBEntities entities = new WorkBountyDBEntities())
         {
             entities.Configuration.ValidateOnSaveEnabled = false;
             string remarks = id.Remarks.ToString();
             Workitem remark = new Workitem() { WorkitemID = id.WorkItemID, Remarks = id.Remarks };
             entities.Workitems.Attach(remark);
             entities.Entry(remark).Property(u => u.Remarks).IsModified = true;
             entities.SaveChanges();
         }
         List<WorkItemAssignment> checkUploadedWorkitem = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).ToList();
         foreach (var data in checkUploadedWorkitem)
         {
             WorkItemAssignment item = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).FirstOrDefault();
             item.IsRewarded = true;
             entity.SaveChanges();
         }
         return "Success";
     }
     catch (Exception)
     {
         return "Error";
     }
 }
        public string EditWorkitem(Workitem id)
        {
            try
            {
                using (var entities = new WorkBountyDBEntities())
                {
                    var getWorkitemData = entities.Workitems.Where(x => x.WorkitemID==id.WorkitemID).ToList();
                    getWorkitemData.ForEach(a =>
                    {
                        if(id.Amount!=null) a.Amount = id.Amount;
                         a.ModifyBy = id.ModifyBy;
                        if (id.ModifyDateTime != null) a.ModifyDateTime = id.ModifyDateTime;
                         a.PublishedTo = id.PublishedTo;
                        if (id.Summary != null) a.Summary = id.Summary;
                        if (id.Title != null) a.Title = id.Title;
                        if (id.ProposedReward != "undefined") a.ProposedReward = id.ProposedReward;
                    }

               );
                    WorkitemStatu workitemstatusData = new WorkitemStatu();
                    string statusDescription = "Update";
                    workitemstatusData.StatusDescription = statusDescription;
                    workitemstatusData.WorkitemID = id.WorkitemID;
                    entities.WorkitemStatus.Add(workitemstatusData);
                    entities.SaveChanges();
                    WorkitemHistory workitemHistoryData = new WorkitemHistory();
                    workitemHistoryData.WorkitemID = id.WorkitemID;
                    workitemHistoryData.UpdatedBy = id.ModifyBy;
                    workitemHistoryData.UpdatedDateTIme = DateTime.Now;
                    var getWorkitemStatusID = entities.WorkitemStatus.Where(s => s.WorkitemID == id.WorkitemID).Select(s => s.WorkitemStatusID).FirstOrDefault();
                    workitemHistoryData.WorkitemStatusID = getWorkitemStatusID;
                    entities.WorkitemHistories.Add(workitemHistoryData);
                    entities.SaveChanges();

                }

                return "Success";
            }
            catch (Exception)
            {
                return "Error";
            }
        }