public PipeReturningRecord(string key, ReturningNotice notice, Pipe pipe, DateTime dateCreated)
     : base(key)
 {
     this.ReturningNotice = notice;
     this.Pipe = pipe;
     this.DateCreated = dateCreated;
 }
        public ActionResult Create(string Key, string Instruction)
        {
            Account onlineAccount = UserSession.OnlineAccount;

            Key = onlineAccount.DetectionCompany.Code + Key;
            ReturningNotice notice = new ReturningNotice(Key,  onlineAccount, DateTime.Now, Instruction);
            notice.State = ReturningNoticeState.Created;

            if (repository.FindByNotCache(Key) != null)
            {
                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("退料通知单号{0}已存在,请尝试使用其他编号", Key) };
                TempData["InvalidModel"] = notice;
            }
            if (onlineAccount == null)
            {
                TempData["InvalidModel"] = notice;
                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("退料通知单({0})添加成功", Key), DisappearDelay = 5000, Type = HintMessageType.Error };
            }
            else
            {
                repository.Add(notice);
                unitOfWork.Commit();

                TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("退料通知单({0})添加成功", Key), DisappearDelay = 5000 };
            }

            return RedirectToAction("Add");
        }