Пример #1
0
        public TSStatusModel GetData(int detailId)
        {
            var entity = Entities.CRFDetails.Where(x => x.DetailsId == detailId).FirstOrDefault();

            if (entity != null)
            {
                var model = new TSStatusModel()
                {
                    Status = 0
                };
                var data = Entities.Studies.Where(x => x.StudyId == entity.StudyId).FirstOrDefault();
                if (data != null)
                {
                    model.StudyNumber   = data.StudyNumber;
                    model.SiteId        = data.SiteId;
                    model.SubjectId     = entity.SubjectId;
                    model.ProtocolTitle = entity.ProtocoTitle;
                    model.Status        = 1;
                    return(model);
                }
            }
            return(new TSStatusModel()
            {
                Status = -1
            });
        }
Пример #2
0
        public ActionResult SaveStart(TSStatusModel model)
        {
            var dal = GetDAL <StepCinemaDataLayer.DataAccess.CRFStatusLayer>();

            if (ModelState.IsValid)
            {
                dal.SaveData(model);
            }
            else
            {
                var errors = ModelState.Keys.SelectMany(k => ModelState[k].Errors)
                             .Select(m => m.ErrorMessage).ToArray();
                return(CamelJson(new { InValid = true, errors }));
            }
            return(CamelJson(new { Model = model }));
        }
Пример #3
0
        public void SaveData(TSStatusModel model)
        {
            if (model == null)
            {
                throw new Exception("Model is Empty");
            }
            var data = Entities.Studies.Where(x => x.StudyNumber == model.StudyNumber).Select(x => new { x.SiteId, x.StudyId }).FirstOrDefault();

            if (data == null)
            {
                model.Status = 0;
                return;
            }
            if ((!string.IsNullOrWhiteSpace(model.SiteId)) && string.Equals(model.SiteId, data.SiteId, StringComparison.InvariantCultureIgnoreCase))
            {
                var dataDetailId = Entities.CRFDetails
                                   .Where(x => x.StudyId == data.StudyId && x.SubjectId == model.SubjectId)
                                   .Select(x => x.DetailsId)
                                   .FirstOrDefault();
                if (dataDetailId == 0 && model.DetailId <= 0)
                {
                    var detail = new EntityModel.CRFDetail();
                    detail.StudyId      = data.StudyId;
                    detail.SubjectId    = model.SubjectId;
                    detail.RegisteredNo = model.RegisteredNo;
                    detail.ScreeningNo  = model.ScreeningNo;
                    detail.ProtocoTitle = model.ProtocolTitle;
                    detail.Status       = (int)StepCinemaModels.Constants.CRFDetailStatus.New;
                    Entities.CRFDetails.Add(detail);
                    Entities.SaveChanges();
                    model.DetailId = detail.DetailsId;
                    model.Status   = 1;
                }
                else if (dataDetailId == model.DetailId)
                {
                    model.Status = 1;
                    var entity = Entities.CRFDetails.Where(x => x.DetailsId == model.DetailId).FirstOrDefault();
                    entity.ProtocoTitle = model.ProtocolTitle;
                    Entities.SaveChanges();
                }
                else
                {
                    model.Status = -100;
                }
            }
            return;
        }