Example #1
0
        public async Task<IActionResult> Edit( string UserName, DoctorViewModel doctorVM )
        {
            if ( doctorVM == null )
                return NotFound();

            var doctor = doctorVM.GetNewDoctor();
            await _doctorRepository.UpdateAsync( UserName, doctor );
            await _userRepository.UpdateAsync( doctorVM.UserName, doctor );

            return RedirectToAction(nameof(List));

        } // Edit
Example #2
0
        public async Task<IActionResult> Create( DoctorViewModel doctorVM )
        {
            if ( ModelState.IsValid )
            {
                var doc = doctorVM.GetNewDoctor();
                doc.UserName = doc.Email;
                doc.NormalizedEmail = doc.Email.ToUpper();
                doc.NormalizedUserName = doc.UserName.ToUpper();
                doc = await _doctorRepository.CreateAsync( doc );
                await _userManager.AddToRoleAsync( doc, Roles.DOCTOR );
                return RedirectToAction( nameof( List ) );
            }
            return View( doctorVM );

        } // Create