Beispiel #1
0
        public async Task <IActionResult> Put([FromRoute] Guid Id, [FromBody] DoctorCategory obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Id != obj.Id)
            {
                return(BadRequest());
            }

            _context.Entry(obj).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public static List <DoctorCategory> GetDoctorCategory()
        {
            List <DoctorCategory> lstDocCat = new List <DoctorCategory>();
            DoctorCategory        oDoctorCategory;
            DatabaseConnection    con = new DatabaseConnection();
            string sql = @"SELECT * FROM DoctorCategory_T";

            try
            {
                SqlCommand    cmd = new SqlCommand(sql, con.GetSqlConnection());
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    oDoctorCategory            = new DoctorCategory();
                    oDoctorCategory.Id         = Convert.ToInt32(dr["doctor_cat_id"]);
                    oDoctorCategory.DocCatName = Convert.ToString(dr["doc_cat_name"]);
                    lstDocCat.Add(oDoctorCategory);
                }
            }
            catch (Exception r)
            {
                lstDocCat = null;
            }
            finally
            {
                con.CloseConnection();
            }
            return(lstDocCat);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DoctorCategory = await _context.DoctorCategories.FirstOrDefaultAsync(m => m.Id == id);

            if (DoctorCategory == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DoctorCategory = await _context.DoctorCategories.FindAsync(id);

            if (DoctorCategory != null)
            {
                _context.DoctorCategories.Remove(DoctorCategory);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #5
0
        public ActionResult Save(DoctorCategory category)
        {
            if (!ModelState.IsValid)
            {
                return(View("DoctorCategoryForm", category));
            }

            if (category.Id == 0)
            {
                _repository.Create(category);
            }
            else
            {
                _repository.Update(category);
            }

            return(RedirectToAction("Index", "DoctorCategories"));
        }
Beispiel #6
0
        public ActionResult New()
        {
            var category = new DoctorCategory();

            return(View("DoctorCategoryForm", category));
        }