Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Row,DoctorID,Name,Family,Image,OfficeImage,BirthDate,MyProperty,Desc")] Doctor doctor)
        {
            if (id != doctor.DoctorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(doctor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DoctorExists(doctor.DoctorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(doctor));
        }
Beispiel #2
0
        public async Task <string> EditDoki(DoctorsCreateEditViewModel viewModel, int?id)
        {
            if (ModelState.IsValid)
            {
                //var tempid = await _context.doctors.FirstOrDefaultAsync(m => m.DoctorID == id);
                //if (tempid==null)
                //{
                //    return "مشخصات چنین پزشکی یافت نشد";
                //}
                //else
                //{
                Doctor doctor = new Doctor()
                {
                    Row         = viewModel.Row,
                    Name        = viewModel.Name,
                    DoctorID    = viewModel.DoctorID,
                    BirthDate   = viewModel.BirthDate,
                    Desc        = viewModel.Desc,
                    Family      = viewModel.Family,
                    Image       = viewModel.Image,
                    MyProperty  = viewModel.MyProperty,
                    OfficeImage = viewModel.OfficeImage,
                };
                _context.Update(doctor);
                await _context.SaveChangesAsync();

                return("اطلاعات با موفقیت بروز رسانی شد");
                //}
            }
            else
            {
                return("عدم بروز رسانی");
            }
        }