Ejemplo n.º 1
0
 public string UpdateDoctor(int id, Doctor doctor)
 {
     doctor.IdDoctor = id;
     context.Attach(doctor);
     context.Entry(doctor).Property("FirstName").IsModified = true;
     context.Entry(doctor).Property("LastName").IsModified  = true;
     context.Entry(doctor).Property("Email").IsModified     = true;
     context.SaveChangesAsync();
     return("Update successful");
 }
Ejemplo n.º 2
0
        public Doctor deleteDoctor(Doctor doc)
        {
            var doct = context.Doctor.FirstOrDefault(s => s.IdDoctor == doc.IdDoctor);

            if (doct == null)
            {
                return(null);
            }
            context.Attach(doct);
            context.Remove(doct);
            context.SaveChanges();
            return(doct);
        }
Ejemplo n.º 3
0
        public CreatedClientResponse CreateClient(CreateClientRequest client)
        {
            var generatedSalt = CreateSalt();
            var pass          = Create(client.Password, generatedSalt);

            int idClient = db.Client.Max(d => d.IdClient) + 1;

            var clt = new Client
            {
                IdClient     = idClient,
                FirstName    = client.FirstName,
                LastName     = client.LastName,
                Email        = client.Email,
                Phone        = client.Phone,
                Login        = client.Login,
                Password     = pass,
                salt         = generatedSalt,
                RefreshToken = ""
            };

            var clientToReturn = new CreatedClientResponse
            {
                IdClient  = idClient,
                FirstName = client.FirstName,
                LastName  = client.LastName,
                Email     = client.Email,
                Phone     = client.Phone,
                Login     = client.Login
            };

            db.Attach(clt);
            db.Add(clt);
            db.SaveChanges();

            var exist = db.Client.Where(c => c.IdClient == idClient).Count();

            if (exist == 1)
            {
                return(clientToReturn);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        public IActionResult UpdateDoctor(ChangeRequest doc)
        {
            var doctor = _context.Doctor.Where(dc => dc.IdDoctor == doc.IdDoctor);

            Doctor changed = new Doctor {
                IdDoctor = doc.IdDoctor, FirstName = doc.FirstName, LastName = doc.LastName
            };

            _context.Attach(changed);
            _context.Entry(changed).Property("FirstName").IsModified = true;
            _context.Entry(changed).Property("LastName").IsModified  = true;
            _context.Entry(changed).Property("Email").IsModified     = true;
            _context.SaveChanges();

            return(Ok("Zaktualizowano doktora o numerze:" + changed.IdDoctor));
        }