public DrugModel DetailsMethod(int?id)
        {
            //var dr=new DrugModel();
            DrugModel dr = new DrugModel();

            using (var drugr = new DrugRespo())
            {
                if (id.HasValue && id != 0)
                {
                    Drug _drug = drugr.GetById(id.Value);

                    dr.DrugId = _drug.DrugId;

                    dr.DrugCode        = _drug.DrugCode;
                    dr.DrugName        = _drug.DrugName;
                    dr.DrugCategory    = _drug.DrugCategory;
                    dr.DrugDescription = _drug.DrugDescription;
                    dr.DrugQuantity    = _drug.DrugQuantity;
                    dr.Status          = _drug.Status;
                    dr.DrugType        = _drug.DrugType;
                    dr.DrugPrice       = _drug.DrugPrice;
                }
                return(dr);
            }
        }
 public void PostDeleteMethod(int id)
 {
     using (var drugr = new DrugRespo())
     {
         if (id != 0)
         {
             // var _drug = drugr.GetById(id);
             Drug _drug = drugr.GetById(id);
             drugr.Delete(_drug);
         }
     }
 }
        public DrugModel GetDrugId(int?id)
        {
            //var dr=new DrugModel();
            DrugModel dr = new DrugModel();

            using (var drugr = new DrugRespo())
            {
                if (id != null)
                {
                    var _drug = drugr.GetById(id.Value);
                    // Drug _drug = drugr.GetById(id.Value);
                    dr.DrugId = _drug.DrugId;
                }

                return(dr);
            }
        }
        public DrugModel GetDeleteMethod(int id)
        {
            DrugModel dr = new DrugModel();

            using (var drugr = new DrugRespo())
            {
                if (id != 0)
                {
                    Drug _drug = drugr.GetById(id);
                    dr.DrugId          = _drug.DrugId;
                    dr.DrugCode        = _drug.DrugCode;
                    dr.DrugName        = _drug.DrugName;
                    dr.DrugCategory    = _drug.DrugCategory;
                    dr.DrugDescription = _drug.DrugDescription;
                    dr.DrugQuantity    = _drug.DrugQuantity;
                    dr.Status          = _drug.Status;
                    dr.DrugPrice       = _drug.DrugPrice;
                    dr.DrugType        = _drug.DrugType;
                }
                return(dr);
            }
        }
        public DrugModel PostReviewMethod(DrugModel model)
        {
            using (var drugr = new DrugRespo())
            {
                if (model.DrugId == 0)
                {
                    Drug _drug = new Drug
                    {
                        DrugId          = model.DrugId,
                        DrugCode        = model.DrugCode,
                        DrugName        = model.DrugName,
                        DrugCategory    = model.DrugCategory,
                        DrugDescription = model.DrugDescription,
                        DrugQuantity    = model.DrugQuantity,
                        Status          = model.Status,
                        DrugPrice       = model.DrugPrice,
                        DrugType        = model.DrugType,
                    };
                    drugr.Insert(_drug);
                }
                else
                {
                    //var _drug = drugr.GetById(dr.DrugId);
                    Drug _drug = drugr.GetById(model.DrugId);
                    _drug.DrugId          = model.DrugId;
                    _drug.DrugCode        = model.DrugCode;
                    _drug.DrugName        = model.DrugName;
                    _drug.DrugCategory    = model.DrugCategory;
                    _drug.DrugDescription = model.DrugDescription;
                    _drug.DrugQuantity    = model.DrugQuantity;
                    _drug.Status          = model.Status;
                    _drug.DrugPrice       = model.DrugPrice;
                    _drug.DrugType        = model.DrugType;

                    drugr.Update(_drug);
                }
                return(model);
            }
        }