Exemplo n.º 1
0
        public ActionResult UpdateTmcListChildrens([DataSourceRequest] DataSourceRequest request, TmcOffViewModel dictionary)
        {
            EXP_DrugDeclaration drugDeclaration = null;

            if (dictionary.RefExtertiseStatement != null)
            {
                drugDeclaration = db.EXP_DrugDeclaration
                                  .FirstOrDefault(d => d.Id == dictionary.RefExtertiseStatement.Value);
            }

            TmcOff tmcOff = db.TmcOffs.First(o => o.Id == dictionary.Id);

            tmcOff.StateType   = dictionary.StateType;
            tmcOff.CreatedDate = dictionary.CreatedDate;
            tmcOff.Count       = dictionary.Count;
            tmcOff.Note        = dictionary.Note;
            tmcOff.StateType   = dictionary.StateType;
            if (drugDeclaration != null)
            {
                tmcOff.ExpertiseStatementId      = dictionary.RefExtertiseStatement;
                tmcOff.ExpertiseStatementNumber  = drugDeclaration.Number;
                tmcOff.ExpertiseStatementTypeStr = drugDeclaration.EXP_DIC_Type.NameRu;
            }

            db.SaveChanges();

            var item = db.TmcOffViews.First(o => o.Id == tmcOff.Id);

            dictionary.CreatedEmployeeValue = item.CreatedEmployeeValue;
            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 2
0
        public ActionResult CreateTmcUseOff([DataSourceRequest] DataSourceRequest request, TmcUseOffView model)
        {
            string           expertiseNumber = null;
            TmcOffRepository repository      = new TmcOffRepository();

            if (model.RefExtertiseStatement != null)
            {
                DrugDeclarationRepository ddRepo = new DrugDeclarationRepository();
                var exp = ddRepo.GetById(model.RefExtertiseStatement.Value);

                if (exp != null)
                {
                    expertiseNumber = exp.Number;
                }
            }

            TmcOff tmc = new TmcOff()
            {
                Id                       = Guid.NewGuid(),
                StateType                = model.StateType,
                CreatedDate              = DateTime.Now,
                CreatedEmployeeId        = UserHelper.GetCurrentEmployee().Id,
                Count                    = model.Count,
                Note                     = model.Note,
                TmcOutId                 = model.TmcOutId,
                TmcId                    = model.TmcId,
                ExpertiseStatementId     = model.RefExtertiseStatement,
                ExpertiseStatementNumber = expertiseNumber
            };

            repository.Insert(tmc);
            repository.Save();

            return(Json(new[] { tmc }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 3
0
        public ActionResult CreateTmcListChildrens([DataSourceRequest] DataSourceRequest request, TmcOffViewModel dictionary)
        {
            string expertiseNumber = null;

            if (dictionary.RefExtertiseStatement != null)
            {
                expertiseNumber = db.Documents.Where(d => d.Id == dictionary.RefExtertiseStatement.Value)
                                  .Select(d => d.Number)
                                  .FirstOrDefault();
            }

            TmcOff tmc = new TmcOff()
            {
                Id                       = Guid.NewGuid(),
                StateType                = dictionary.StateType,
                CreatedDate              = DateTime.Now,
                CreatedEmployeeId        = UserHelper.GetCurrentEmployee().Id,
                Count                    = dictionary.Count,
                Note                     = dictionary.Note,
                TmcOutId                 = Guid.Parse(dictionary.TmcOutIdString),
                ExpertiseStatementId     = dictionary.RefExtertiseStatement,
                ExpertiseStatementNumber = expertiseNumber
            };

            db.TmcOffs.Add(tmc);
            db.SaveChanges();

            dictionary.Id = tmc.Id;
            var item = db.TmcOffViews.First(o => o.Id == tmc.Id);

            dictionary.CreatedEmployeeValue = item.CreatedEmployeeValue;
            dictionary.StateTypeValue       = "На списании";

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 4
0
        public ActionResult DestroyTmcListChildrens([DataSourceRequest] DataSourceRequest request, TmcOffView dictionary)
        {
            if (dictionary != null)
            {
                TmcOff d = db.TmcOffs.First(o => o.Id == dictionary.Id);
                db.TmcOffs.Remove(d);
                db.SaveChanges();
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 5
0
 public ActionResult DestroyTmcUseOff([DataSourceRequest] DataSourceRequest request, TmcUseOffView model)
 {
     if (model != null)
     {
         TmcOffRepository repository = new TmcOffRepository();
         TmcOff           d          = repository.GetById(model.Id);
         repository.Delete(d);
         repository.Save();
     }
     return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
 }