Esempio n. 1
0
        public ActionResult AddAssyOutsComments1(AssemblyOutputRemarks assyRemarks)
        {
            var isExistAssyRemarks = (from assyRemarks1 in pdDBContext.AssemblyRemarks
                                      where assyRemarks1.AssemblyOutsID == assyRemarks.AssemblyOutsID
                                      select new
            {
                Remarks = assyRemarks1.Remarks
            }).ToList();



            if (ModelState.IsValid)
            {
                if (isExistAssyRemarks.Count == 0)
                {
                    AssemblyOutputRemarks addAssyRemarks = new AssemblyOutputRemarks();

                    addAssyRemarks.AssemblyOutsID = assyRemarks.AssemblyOutsID;
                    addAssyRemarks.Remarks        = assyRemarks.Remarks;
                    addAssyRemarks.Operation      = assyRemarks.Operation;
                    addAssyRemarks.CreatedBy      = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    addAssyRemarks.DateCreated    = DateTime.Now;
                    addAssyRemarks.ModifiedBy     = null;
                    addAssyRemarks.DateModified   = null;

                    pdDBContext.AssemblyRemarks.Attach(addAssyRemarks);
                    pdDBContext.AssemblyRemarks.Add(addAssyRemarks);
                    pdDBContext.SaveChanges();
                }

                else
                {
                    AssemblyOutputRemarks updateAssyRemarks = pdDBContext.AssemblyRemarks.FirstOrDefault(assy => assy.AssemblyOutsID == assyRemarks.AssemblyOutsID);

                    updateAssyRemarks.Remarks      = assyRemarks.Remarks;
                    updateAssyRemarks.Operation    = assyRemarks.Operation;
                    updateAssyRemarks.ModifiedBy   = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                    updateAssyRemarks.DateModified = DateTime.Now;

                    pdDBContext.Entry(updateAssyRemarks).State = System.Data.EntityState.Modified;
                    pdDBContext.SaveChanges();
                }
            }


            //if (addAssyRemarks == null)
            //{

            //}

            //else
            //{

            //   // return RedirectToAction("UpdateComments", details);
            //}


            return(View());
        }
Esempio n. 2
0
        public ActionResult UpdateComments(TestOutputRemarks comments)
        {
            TestOutputRemarks updateComments = pdDBContext.Remarks.FirstOrDefault(c => c.TestOutputID == comments.TestOutputID);

            HistoricalRemarks addRemarksLogs = new HistoricalRemarks();

            if (comments.Remarks != null)
            {
                addRemarksLogs.GUID            = System.Guid.NewGuid().ToString().ToUpper();
                addRemarksLogs.Department      = "TEST";
                addRemarksLogs.Operation       = "MovesToFG";
                addRemarksLogs.ConnectorID     = comments.TestOutputID;
                addRemarksLogs.UpdatedRemarks  = comments.Remarks;
                addRemarksLogs.OriginalRemarks = updateComments.Remarks;
                addRemarksLogs.CreatedBy       = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                addRemarksLogs.DateAdded       = DateTime.Now;

                pdDBContext.RemarksLogs.Attach(addRemarksLogs);
                pdDBContext.RemarksLogs.Add(addRemarksLogs);
                pdDBContext.SaveChanges();
            }


            if (updateComments != null)
            {
                updateComments.ModifiedBy   = Common.GetWebCurrentUser(Common.WebUserInformation.Username);
                updateComments.DateModified = DateTime.Now;
                updateComments.Remarks      = comments.Remarks;
            }

            using (var dbContext = new ProductionDashboardDBContext())
            {
                dbContext.Entry(updateComments).State = System.Data.EntityState.Modified;
                dbContext.SaveChanges();
            }

            return(View());
        }