- Migliorie

This commit is contained in:
DawitG96
2019-02-01 19:57:23 +01:00
parent 44e9542a15
commit 949184875a
11 changed files with 170 additions and 153 deletions

View File

@@ -13,14 +13,11 @@ using System.Net.Http.Headers;
namespace IdentityDemo.Controllers
{
[ApiExplorerSettings(IgnoreApi = true)]
[Route("[controller]/[action]")]
public class AccountController : BaseController
{
private static readonly string NoteModified = "Il tuo dottore ha modificato la nota per te";
private static readonly string InvalidLogIn = "Username o Password sbagliati";
private static readonly string AlreadyLogIn = "L'utente e' gia' loggato";
private static readonly string UsernameDupl = "Lo username selezionato e' gia' in uso";
private static readonly string ModNotExists = "L'oggetto da modificare non esiste";
private static readonly string AlreadyPatie = "Sei gia' un paziente";
private static readonly string DocNotExists = "Il dottore selezionato non esiste";
@@ -105,11 +102,10 @@ namespace IdentityDemo.Controllers
}
[HttpPost]
public async Task<IActionResult> _modify(User user)
public async Task<IActionResult> _modify(User user, Doctor doctor)
{
return await LoggedAccessDataOf(user.Username, false, () => {
var usr = Db.Users.Where(u => u.Username.Equals(user.Username)).FirstOrDefault();
if (user.Password.Equals(""))
user.Password = usr.Password;
if (user.Avatar.Equals(""))
@@ -120,8 +116,20 @@ namespace IdentityDemo.Controllers
user.LastName = usr.LastName;
if (user.Name.Equals(""))
user.Name = usr.Name;
Db.UpdateAsync(user);
var doc = Db.Doctors.Where(d => d.Username.Equals(user.Username)).FirstOrDefault();
if(doc!=null)
{
if (!doctor.PhoneNumber.Equals(""))
doc.PhoneNumber = doctor.PhoneNumber;
if (!doctor.Schedule.Equals(""))
doc.Schedule = doctor.Schedule;
Db.UpdateAsync(doc);
}
return Json(OkJson);
});
}

View File

@@ -6,12 +6,12 @@ using System.Linq;
namespace SeniorAssistant.Controllers
{
[ApiExplorerSettings(IgnoreApi = true)]
public class HomeController : BaseController
{
[Route("")]
[Route("Home")]
[Route("Index")]
[Route("Login")]
public IActionResult Login()
{
return CheckUnAuthorized("Login");
@@ -88,7 +88,7 @@ namespace SeniorAssistant.Controllers
{
if (IsLogged())
{
return RedirectToAction("Profile", "Home", GetUser(HttpContext.Session.GetString(Username)));
return RedirectToAction("Profile", "Home");
}
var forgot = Db.Forgot.Where(f => f.Username.Equals(username)).FirstOrDefault();
@@ -101,7 +101,8 @@ namespace SeniorAssistant.Controllers
{
if (!IsLogged())
{
return RedirectToAction("Login", "Home", "/" + view);
model = "/" + view;
view = "Login";
}
return View(view, model);
}
@@ -110,7 +111,7 @@ namespace SeniorAssistant.Controllers
{
if (IsLogged())
{
return RedirectToAction("Profile", "Home", GetUser(HttpContext.Session.GetString(Username)));
return RedirectToAction("Profile", "Home");
}
return View(view, model);
}