예제 #1
0
        public int Insert(CommonTestSetupModel model)
        {
            int i = 0;

            using (EHMSEntities ent = new EHMSEntities())
            {
                var objToSave = AutoMapper.Mapper.Map <CommonTestSetupModel, HospitalExtraTest>(model);
                try
                {
                    objToSave.CreatedBy        = Utility.GetCurrentLoginUserId();
                    objToSave.CreatedDate      = DateTime.Now;
                    objToSave.Vat              = 0;
                    objToSave.VatAmount        = 0;
                    objToSave.CommonTestTypeId = 1;
                    objToSave.Status           = true;
                    ent.HospitalExtraTests.Add(objToSave);
                    i = ent.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
            return(i);
        }
예제 #2
0
        public ActionResult Edit(int id)
        {
            CommonTestSetupModel  model = new CommonTestSetupModel();
            CommonTestSetProvider pro   = new CommonTestSetProvider();

            model = pro.GetList().Where(x => x.HospitalExtraTestId == id).FirstOrDefault();
            return(View(model));
        }
예제 #3
0
        //
        // GET: /CommonTest/

        public ActionResult Index()
        {
            CommonTestSetProvider pro   = new CommonTestSetProvider();
            CommonTestSetupModel  model = new CommonTestSetupModel();

            model.CommonTestList = pro.GetList().Where(x => x.Status == true).ToList();

            return(View(model));
        }
예제 #4
0
        public ActionResult Edit(CommonTestSetupModel model)
        {
            CommonTestSetProvider pro = new CommonTestSetProvider();
            int i = pro.Update(model);

            if (i != 0)
            {
                TempData["success"] = HospitalManagementSystem.UtilityMessage.edit;
                return(RedirectToAction("index"));
            }
            return(View(model));
        }
예제 #5
0
        public ActionResult Create(CommonTestSetupModel model)
        {
            CommonTestSetProvider pro = new CommonTestSetProvider();
            int i = pro.Insert(model);

            if (i != 0)
            {
                TempData["success"] = HospitalManagementSystem.UtilityMessage.save;
                return(RedirectToAction("Index"));
            }

            return(View());
        }
예제 #6
0
        public int Update(CommonTestSetupModel model)
        {
            int i = 0;

            using (EHMSEntities ent = new EHMSEntities())
            {
                var objToEdit = ent.HospitalExtraTests.Where(x => x.HospitalExtraTestId == model.HospitalExtraTestId).FirstOrDefault();
                model.CommonTestTypeId = 1;
                AutoMapper.Mapper.Map(model, objToEdit);


                ent.Entry(objToEdit).State = System.Data.EntityState.Modified;
                i = ent.SaveChanges();
            }

            return(i);
        }