Refactoring api

This commit is contained in:
2019-01-04 18:26:00 +01:00
parent 3751680fd3
commit ed4597e6b3
9 changed files with 149 additions and 100 deletions

View File

@@ -13,7 +13,7 @@ namespace IdentityDemo.Controllers
[Route("[controller]/[action]")]
public class AccountController : BaseController
{
private readonly JsonResponse OkJson = new JsonResponse();
private static readonly string NoteModified = "Il tuo dottore ha modificato la nota per te";
[HttpPost]
public ActionResult _login(string username, string password)
@@ -35,9 +35,8 @@ namespace IdentityDemo.Controllers
HttpContext.Session.SetString(Username, username);
HttpContext.Session.SetString("email", user.Email);
HttpContext.Session.SetString("name", user.Name);
//HttpContext.Session.SetString("lastname", user.LastName);
HttpContext.Session.SetString("lastname", user.LastName);
var isDoc = (from d in Db.Doctors
where d.Username.Equals(username)
select d).ToArray().FirstOrDefault() != null;
@@ -168,5 +167,19 @@ namespace IdentityDemo.Controllers
return Json(new JsonResponse());
});
}
[HttpPut]
public ActionResult _addNote(string patient, string text)
{
return LoggedAccessDataOf(patient, () =>
{
var pat = Db.Patients.Where((p) => p.Username.Equals(patient)).FirstOrDefault();
pat.Notes = text;
Db.Update(pat);
_notification(patient, NoteModified);
return Json(OkJson);
});
}
}
}