public Drug_PropertiesModel PostEditMethod(Drug_PropertiesModel model)
        {
            using (var drugr = new DrugpropRepository())
            {
                if (model.DrugCode == null)
                {
                    Drug_Properties _drug = new Drug_Properties
                    {
                        DrugCode        = model.DrugCode,
                        DrugName        = model.DrugName,
                        DrugCategory    = model.DrugCategory,
                        DrugDescription = model.DrugDescription
                    };
                    drugr.Insert(_drug);
                }
                else
                {
                    //var _drug = drugr.GetById(dr.DrugId);
                    Drug_Properties _drug = drugr.GetById(model.DrugCode);
                    _drug.DrugCode        = model.DrugCode;
                    _drug.DrugName        = model.DrugName;
                    _drug.DrugCategory    = model.DrugCategory;
                    _drug.DrugDescription = model.DrugDescription;

                    drugr.Update(_drug);
                }
                return(model);
            }
        }
 public void PostDeleteMethod(string id)
 {
     using (var drugr = new DrugpropRepository())
     {
         if (id != null)
         {
             Drug_Properties _drug = drugr.GetById(id);
             drugr.Delete(_drug);
         }
     }
 }
        public Drug_PropertiesModel GetDrugpropId(string id)
        {
            Drug_PropertiesModel dr = new Drug_PropertiesModel();

            using (var drugp = new DrugpropRepository())
            {
                if (id != null)
                {
                    var _drug = drugp.GetById(id);
                    dr.DrugCode = _drug.DrugCode;
                }
                return(dr);
            }
        }
        public void CreateMethod(DrugModel model, string DrugType)
        {
            DrugpropRepository dp = new DrugpropRepository();

            using (var drugr = new DrugRespo())
            {
                if (model.DrugId == 0)
                {
                    Drug _drug = new Drug();
                    //_drug.DrugId = model.DrugId;
                    _drug.DrugCode        = model.DrugCode;
                    _drug.DrugName        = dp.GetById(model.DrugCode).DrugName + " (" + DrugType + ")";
                    _drug.DrugCategory    = dp.GetById(model.DrugCode).DrugCategory;
                    _drug.DrugDescription = dp.GetById(model.DrugCode).DrugDescription;
                    _drug.DrugQuantity    = model.DrugQuantity;
                    _drug.Status          = "Available";
                    _drug.DrugPrice       = model.DrugPrice;
                    _drug.DrugType        = DrugType;
                    _drug.DateCreated     = DateTime.Now;

                    drugr.Insert(_drug);
                }
            }
        }
        public Drug_PropertiesModel GETeditMethod(string id)
        {
            Drug_PropertiesModel dr = new Drug_PropertiesModel();

            using (var drugr = new DrugpropRepository())
            {
                if (id != null)
                {
                    Drug_Properties _drug = drugr.GetById(id);
                    dr.DrugCode        = _drug.DrugCode;
                    dr.DrugName        = _drug.DrugName;
                    dr.DrugCategory    = _drug.DrugCategory;
                    dr.DrugDescription = _drug.DrugDescription;
                }
                return(dr);
            }
        }