Exemple #1
0
        public ActionResult ActReception(string id)
        {
            var assess = GetSaDeclarationById(id);
            var model  = new OBK_ActReception();

            if (assess != null)
            {
                var temp = db.OBK_ActReception.FirstOrDefault(o => o.OBK_AssessmentDeclarationId == new Guid(id));

                if (temp != null)
                {
                    model = temp;
                }
                else
                {
                    model.Id = Guid.NewGuid();
                    model.OBK_AssessmentDeclarationId = new Guid(id);
                    db.OBK_ActReception.Add(model);
                    db.SaveChanges();
                }
            }

            ViewData["ContractId"] = assess.ContractId;
            var product = db.OBK_RS_Products.FirstOrDefault(o => o.ContractId == assess.ContractId);

            if (model.Producer == null && product != null)
            {
                repository.UpdateAct(assess, "Producer", model.Id, product.ProducerNameRu,
                                     UserHelper.GetCurrentEmployee().Id.ToString(), "Producer");
            }

            if (model.ActDate == null)
            {
                repository.UpdateAct(assess, "Declarer", model.Id, UserHelper.GetCurrentEmployee().FullName,
                                     UserHelper.GetCurrentEmployee().Id.ToString(), "Declarer");;
            }

            if (model.Declarer == null)
            {
                repository.UpdateAct(assess, "ActDate", model.Id, DateTime.Now.ToString(),
                                     UserHelper.GetCurrentEmployee().Id.ToString(), "ActDate");
            }

            var safetyRepository = new SafetyAssessmentRepository();

            ViewData["ProductSampleList"] =
                new SelectList(safetyRepository.GetProductSamples(), "Id", "Name");

            ViewData["InspectionInstalledList"] =
                new SelectList(safetyRepository.GetInspectionInstalls(), "Id", "Name");

            ViewData["PackageConditionList"] =
                new SelectList(safetyRepository.GetPackageConditions(), "Id", "Name");

            ViewData["StorageConditionsList"] =
                new SelectList(safetyRepository.GetStorageConditions(), "Id", "Name");

            ViewData["MarkingList"] =
                new SelectList(safetyRepository.GetMarkings(), "Id", "Name");

            return(PartialView("ActDeclarationView", model));
        }