Пример #1
0
        public ActionResult NewDocument(FormCollection formValues)
        {
            Guid userGuid = AppContext.GetUserGuid();

            if (userGuid == Guid.Empty)
            {
                return(new HttpUnauthorizedResult());
            }
            Guid documentID = _repository.CreateDocument(userGuid);

            InfoTypeOne infoTypeOne = new InfoTypeOne()
            {
                DocumentID = documentID
            };
            InfoTypeTwo infoTypeTwo = new InfoTypeTwo()
            {
                DocumentID = documentID
            };

            if (AppContext.AllowInfoTypeOneWrite())
            {
                UpdateModel <InfoTypeOne>(infoTypeOne);
            }

            if (AppContext.AllowInfoTypeTwoWrite())
            {
                UpdateModel <InfoTypeTwo>(infoTypeTwo);
            }

            if (AppContext.AllowScansWrite())
            {
                string[]    scansGuids = formValues["selectedScans"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List <Guid> guidsList  = new List <Guid>();
                foreach (var guid in scansGuids)
                {
                    guidsList.Add(new Guid(guid));
                }
                _repository.SetDocumentScans(guidsList, documentID);
            }

            string[] senderIDs = formValues["sendersIDs"].Split(',');
            foreach (string sid in senderIDs)
            {
                int tmp;
                if (!int.TryParse(sid, out tmp))
                {
                    continue;
                }
                _repository.AddSender(documentID, tmp);
            }

            //poza ifami poniewa¿ i tak tworzymy "wydmuszki" sekcji
            _repository.CreateInfoTypeOne(infoTypeOne);
            _repository.CreateInfoTypeTwo(infoTypeTwo);

            _repository.SubmitChanges();
            return(RedirectToAction("Index", "Scans", new { documentID = documentID }));
        }
Пример #2
0
 public void CreateInfoTypeTwo(InfoTypeTwo infoTypeTwo)
 {
     _context.InfoTypeTwos.InsertOnSubmit(infoTypeTwo);
 }