Exemplo n.º 1
0
        //public ReleaseCP getReleseCPDataForView(int ReleseCPID)
        //{
        //    using (IReleaseCPRepository db = new ReleaseCPRepository())
        //    {
        //        ReleaseCP ReleaseCPUpdated = db.FindSingle(m => m.ReleaseCPID == ReleaseCPView.ReleaseCPID).
        //        return DbSet.AsNoTracking().Where(r => r.ReleaseCPID == ReleseCPID).FirstOrDefault().Include(r=>r.Publication);

        //}
        //public int Edit(ReleaseCPView ReleaseCPView)
        //{
        //    int Count = 0;
        //    using (IReleaseCPRepository db = new ReleaseCPRepository())
        //    {
        //        ReleaseCP ReleaseCPUpdated = db.FindSingle(m => m.ReleaseCPID == ReleaseCPView.ReleaseCPID);
        //        ReleaseCPUpdated.PublicationID = ReleaseCPView.PublicationID == 0 ? null : ReleaseCPView.PublicationID;
        //        ReleaseCPUpdated.ExceptionIndicator = ReleaseCPView.ExceptionIndicator;
        //        ReleaseCPUpdated.ExceptionDate = ReleaseCPView.ExceptionDate;
        //        ReleaseCPUpdated.ExceptionRemarks = ReleaseCPView.ExceptionRemarks;
        //        ReleaseCPUpdated.DelayReason = ReleaseCPView.DelayReason;
        //        ReleaseCPUpdated.DelayReasonHistory = ReleaseCPView.DelayReasonHistory;
        //        ReleaseCPUpdated.Comments = ReleaseCPView.Comments;
        //        ReleaseCPUpdated.IsVisible = ReleaseCPView.IsVisible;
        //        db.Edit(ReleaseCPUpdated);

        //        Count += await db.SaveAsync(User);
        //    }
        //    //if  ReleaseCP edit and PublicationID not null edit PublicationMailDate
        //    //if (Count>0 && (ReleaseCPView.PublicationID ?? 0) > 0 )
        //    //{
        //    //    using (IPublicationRepository db = new PublicationRepository())
        //    //    {
        //    //        Publication Pub = db.Find(ReleaseCPView.PublicationID);
        //    //        Pub.PublicationMailDate = ReleaseCPView.PublicationMailDate;
        //    //        db.Edit(Pub);
        //    //        Count += await db.SaveAsync(User); ;
        //    //    }
        //    //}
        //   return Count;
        //}
        public async Task <int> Edit(ReleaseCPView ReleaseCPView, WindowsPrincipal User)
        {
            //DbSet.AsNoTracking().Where(r => r.ReleaseID == releaseId)
            //  .Include(e => e.ReleaseMilestones)
            int Count = 0;

            using (IReleaseCPRepository db = new ReleaseCPRepository())
            {
                try
                {
                    ReleaseCP ReleaseCPUpdated = db.GetReleaseCPId(ReleaseCPView.ReleaseCPID);
                    ReleaseCPUpdated.PublicationID = ReleaseCPView.PublicationID == 0 ? null : ReleaseCPView.PublicationID;
                    if (ReleaseCPUpdated.Publication != null)
                    {
                        ReleaseCPUpdated.Publication.PublicationMailDate = ReleaseCPView.PublicationMailDate;
                    }
                    ReleaseCPUpdated.ExceptionIndicator = ReleaseCPView.ExceptionIndicator;
                    ReleaseCPUpdated.ExceptionDate      = ReleaseCPView.ExceptionDate;
                    ReleaseCPUpdated.ExceptionRemarks   = ReleaseCPView.ExceptionRemarks;
                    ReleaseCPUpdated.DelayReason        = ReleaseCPView.DelayReason;
                    ReleaseCPUpdated.DelayReasonHistory = ReleaseCPView.DelayReasonHistory;
                    ReleaseCPUpdated.Comments           = ReleaseCPView.Comments;
                    ReleaseCPUpdated.IsDeleted          = ReleaseCPView.IsDeleted;
                    db.Edit(ReleaseCPUpdated);
                }
                catch (Exception ex) { var y = ex; }
                Count += await db.SaveAsync(User);
            }
            return(Count);
        }
Exemplo n.º 2
0
 public async Task <int> Add(ReleaseCPView ReleaseCPView, WindowsPrincipal User)
 {
     using (IReleaseCPRepository db = new ReleaseCPRepository())
     {
         ReleaseCP ReleaseCP = new ReleaseCP
         {
             CPID               = ReleaseCPView.CPID,
             ReleaseID          = ReleaseCPView.ReleaseID,
             ExceptionIndicator = ReleaseCPView.ExceptionIndicator,
             ExceptionDate      = ReleaseCPView.ExceptionDate,
             ExceptionRemarks   = ReleaseCPView.ExceptionRemarks,
             DelayReason        = ReleaseCPView.DelayReason,
             DelayReasonHistory = ReleaseCPView.DelayReasonHistory,
             Comments           = ReleaseCPView.Comments,
             IsDeleted          = ReleaseCPView.IsDeleted
         };
         db.Add(ReleaseCP);
         return(await db.SaveAsync(User));
     }
 }