public HttpResponseMessage AddBloodRequest(BloodRequest request)
        {
            KanTalepleri k = new KanTalepleri()
            {
                Id                   = request.Id,
                HastaId              = request.PatientId,
                KanGrupId            = request.BloodGroupId,
                TalepAciklama        = request.Description,
                TalepTarihi          = DateTime.Now,
                UniteAdet            = request.UnitQuantity,
                BeklenenUnite        = request.WaitingUnit,
                TeminEdilenUniteAdet = request.SuppliedUnit
            };

            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                db.KanTalepleri.Add(k);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    throw e;
                }

                return(Request.CreateResponse(HttpStatusCode.Created, k));
            }
        }
        public HttpResponseMessage addPatient(Patient p)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                Hastalar h = new Hastalar()
                {
                    Ad            = p.Name,
                    Cinsiyet      = p.Gender,
                    DogumTarihi   = p.Birthday,
                    DoktorId      = p.DoctorId,
                    HastaneId     = p.HospitalId,
                    HastaYakiniId = p.RelativeId,
                    KanGrubuId    = p.BloodGroupId,
                    Mail          = p.Email,
                    Soyad         = p.Surname,
                    TcKimlik      = p.IdentificationNo,
                    Telefon       = p.Phone,
                    Hastalik      = p.Disease
                };

                db.Hastalar.Add(h);
                try
                {
                    db.SaveChanges();

                    return(Request.CreateResponse(HttpStatusCode.Created, p));
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
        public HttpResponseMessage GetPatientsByHospital(int id)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                List <Patient> patients = db.Hastalar.Where(x => x.HastaneId == id).Select(p => new Patient()
                {
                    Id               = p.Id,
                    Birthday         = p.DogumTarihi,
                    BloodGroupId     = p.KanGrubuId,
                    Disease          = p.Hastalik,
                    DoctorId         = p.DoktorId,
                    Gender           = p.Cinsiyet,
                    HospitalId       = p.HastaneId,
                    IdentificationNo = p.TcKimlik,
                    Email            = p.Mail,
                    Name             = p.Ad,
                    Surname          = p.Soyad,
                    Phone            = p.Telefon,
                    RelativeId       = p.HastaYakiniId,
                    BloodGroup       = db.KanGruplari.FirstOrDefault(k => k.Id == p.KanGrubuId).KanGrubu
                }).ToList();

                if (patients.Count() > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, patients));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotAcceptable, patients));
                }
            }
        }
 public IEnumerable <Diseases> GetDiseases()
 {
     using (HayatKanaliDB db = new HayatKanaliDB())
     {
         return(db.KalitsalHastaliklar.Select(x => new Diseases()
         {
             Id = x.Id,
             Name = x.HastalikAdi
         }).ToList());
     }
 }
 public IEnumerable <BloodGroup> GetBloodGroups()
 {
     using (HayatKanaliDB db = new HayatKanaliDB())
     {
         return(db.KanGruplari.Select(x => new BloodGroup()
         {
             Id = x.Id,
             Name = x.KanGrubu
         }).ToList());
     }
 }
        public HttpResponseMessage AddClinic(Clinic clinic)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                Klinikler k = new Klinikler()
                {
                    KlinikAdi = clinic.Name,
                    Aciklama  = clinic.Description
                };

                db.Klinikler.Add(k);
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.Created, clinic));
            }
        }
        public HttpResponseMessage EmployeeInfo([FromBody] Employee e)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                Employee employee = db.Personeller.Select(x => new Employee()
                {
                    Id         = x.Id,
                    Email      = x.Mail,
                    HospitalId = x.HastaneId,
                    Name       = x.Ad,
                    Surname    = x.Soyad,
                    Username   = x.KullaniciAdi
                }).FirstOrDefault(x => x.Email == e.Email);

                return(Request.CreateResponse(HttpStatusCode.Accepted, employee));
            }
        }
Exemplo n.º 8
0
        public HttpResponseMessage GetDoctorsByHosptial(int id)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                IEnumerable <Doctor> doctors = db.Doktorlar.Where(x => x.HastaneId == id).Select(d => new Doctor()
                {
                    Id         = d.Id,
                    Email      = d.Mail,
                    HospitalId = d.HastaneId,
                    Name       = d.Ad,
                    Phone      = d.Telefon,
                    Surname    = d.Soyad
                }).ToList();

                return(Request.CreateResponse(HttpStatusCode.OK, doctors));
            }
        }
        public HttpResponseMessage AddEmployee(Employee employee)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                Personeller p = new Personeller()
                {
                    Ad           = employee.Name,
                    Soyad        = employee.Surname,
                    KullaniciAdi = employee.Username,
                    Mail         = employee.Email,
                    Parola       = employee.Password,
                    HastaneId    = employee.HospitalId
                };

                db.Personeller.Add(p);
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.Created, employee));
            }
        }
Exemplo n.º 10
0
        public HttpResponseMessage HospitalInfo([FromBody] Hospital h)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                Hospital hospital = db.Hastaneler.Select(x => new Hospital()
                {
                    Id       = x.Id,
                    Address  = x.Adres,
                    CityId   = x.CityId,
                    District = x.District,
                    Email    = x.Mail,
                    Location = x.Konum,
                    Name     = x.Ad,
                    Phone    = x.Telefon,
                    Username = x.KullaniciAdi
                }).FirstOrDefault(x => x.Email == h.Email);

                return(Request.CreateResponse(HttpStatusCode.Accepted, hospital));
            }
        }
        public HttpResponseMessage addRelative(Relative r)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                HastaYakinlari h = new HastaYakinlari()
                {
                    Ad          = r.Name,
                    Cinsiyet    = r.Gender,
                    DogumTarihi = r.Birthday,
                    Mail        = r.Email,
                    Soyad       = r.Surname,
                    TcKimlik    = r.IdentificationNo,
                    Telefon     = r.Phone
                };

                db.HastaYakinlari.Add(h);

                try
                {
                    db.SaveChanges();

                    var relative = db.HastaYakinlari.Select(x => new Relative()
                    {
                        Id               = x.Id,
                        Birthday         = x.DogumTarihi,
                        Email            = x.Mail,
                        Gender           = x.Cinsiyet,
                        IdentificationNo = x.TcKimlik,
                        Name             = x.Ad,
                        Phone            = x.Telefon,
                        Surname          = x.Soyad
                    }).FirstOrDefault();

                    return(Request.CreateResponse(HttpStatusCode.Created, relative));
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
Exemplo n.º 12
0
        public HttpResponseMessage GetBloodRequestsByUser(int id)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                var user = db.Kullanicilar.FirstOrDefault(x => x.Id == id);

                var s = (from talep in db.KanTalepleri
                         join hastalar in db.Hastalar on talep.HastaId equals hastalar.Id
                         join hastaneler in db.Hastaneler on hastalar.HastaneId equals hastaneler.Id
                         where hastaneler.District == user.District
                         select new
                {
                    RequestId = talep.Id,
                    PatientId = hastalar.Id,
                    PatientName = hastaneler.Ad
                }).ToList();


                return(Request.CreateResponse(HttpStatusCode.OK, s));
            }
        }
Exemplo n.º 13
0
        public HttpResponseMessage UpdateUserParams(User u)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                var user = db.Kullanicilar.Where(x => x.Id == u.Id).FirstOrDefault();

                user.TcKimlik             = u.IdentificationNo;
                user.Telefon              = u.Phone;
                user.KanGrubuId           = u.BloodGroupId;
                user.SigaraAlkolKullanimi = u.UsingSmokingAndAlcohol;
                user.SonKanVermeTarihi    = u.LastBloodDonation;
                user.CityId   = u.CityId;
                user.District = u.District;

                db.SaveChanges();

                var user_bloodGroup = db.KanGruplari.FirstOrDefault(x => x.Id == u.BloodGroupId).KanGrubu;

                User added_user = new User()
                {
                    Id       = user.Id,
                    Name     = user.Ad,
                    Surname  = user.Soyad,
                    Birthday = user.DogumTarihi,
                    Email    = user.Mail,
                    UsingSmokingAndAlcohol = user.SigaraAlkolKullanimi,
                    LastBloodDonation      = user.SonKanVermeTarihi,
                    IdentificationNo       = user.TcKimlik,
                    Phone        = user.Telefon,
                    BloodGroupId = user.KanGrubuId,
                    BloodGroup   = user_bloodGroup.Length > 0 ? user_bloodGroup : null,
                    CityId       = user.CityId,
                    District     = user.District
                };

                return(Request.CreateResponse(HttpStatusCode.OK, added_user));
            }
        }
 public Patient GetPatient(int id)
 {
     using (HayatKanaliDB db = new HayatKanaliDB())
     {
         return(db.Hastalar.Where(x => x.Id == id).Select(p => new Patient()
         {
             Id = p.Id,
             Birthday = p.DogumTarihi,
             BloodGroupId = p.KanGrubuId,
             Disease = p.Hastalik,
             DoctorId = p.DoktorId,
             Gender = p.Cinsiyet,
             HospitalId = p.HastaneId,
             IdentificationNo = p.TcKimlik,
             Email = p.Mail,
             Name = p.Ad,
             Surname = p.Soyad,
             Phone = p.Telefon,
             RelativeId = p.HastaYakiniId,
             BloodGroup = db.KanGruplari.FirstOrDefault(k => k.Id == p.KanGrubuId).KanGrubu
         }).FirstOrDefault());
     }
 }
Exemplo n.º 15
0
        public HttpResponseMessage UserInfo([FromBody] User u)
        {
            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                User user = db.Kullanicilar.Select(x => new User()
                {
                    Id                     = x.Id,
                    Name                   = x.Ad,
                    Surname                = x.Soyad,
                    Birthday               = x.DogumTarihi,
                    BloodGroupId           = x.KanGrubuId,
                    CityId                 = x.CityId,
                    District               = x.District,
                    Email                  = x.Mail,
                    IdentificationNo       = x.TcKimlik,
                    LastBloodDonation      = x.SonKanVermeTarihi,
                    Phone                  = x.Telefon,
                    UsingSmokingAndAlcohol = x.SigaraAlkolKullanimi,
                    BloodGroup             = db.KanGruplari.FirstOrDefault(k => k.Id == x.KanGrubuId).KanGrubu
                }).FirstOrDefault(x => x.Email == u.Email);

                return(Request.CreateResponse(HttpStatusCode.Accepted, user));
            }
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

            using (HayatKanaliDB db = new HayatKanaliDB())
            {
                string pass = Crypto.GetMd5Hash(MD5.Create(), context.Password);

                if (login_type == "default-user")
                {
                    if (db.Kullanicilar.Where(user => user.Mail == context.UserName).FirstOrDefault() != null)
                    {
                        if (db.Kullanicilar.Where(user => user.Parola == pass).FirstOrDefault() != null)
                        {
                            ClaimsIdentity identity = new ClaimsIdentity(context.Options.AuthenticationType);
                            identity.AddClaim(new Claim("sub", context.UserName));
                            identity.AddClaim(new Claim("role", "user"));
                            context.Validated(identity);
                        }
                        else
                        {
                            context.SetError("Wrong Pass", "Parola hatalıdır.");
                        }
                    }
                    else
                    {
                        context.SetError("Not Found User", "Böyle bir kullanıcı kaydı bulunamadı.");
                    }
                }
                else if (login_type == "hospital")
                {
                    if (db.Hastaneler.Where(hos => hos.Mail == context.UserName).FirstOrDefault() != null)
                    {
                        if (db.Hastaneler.Where(hos => hos.Parola == pass).FirstOrDefault() != null)
                        {
                            ClaimsIdentity identity = new ClaimsIdentity(context.Options.AuthenticationType);
                            identity.AddClaim(new Claim("sub", context.UserName));
                            identity.AddClaim(new Claim("role", "user"));
                            context.Validated(identity);
                        }
                        else
                        {
                            context.SetError("Wrong Pass", "Parola hatalıdır.");
                        }
                    }
                    else
                    {
                        context.SetError("Not Found Hospital", "Böyle bir hastane kaydı bulunamadı.");
                    }
                }
                else if (login_type == "employee")
                {
                    if (db.Personeller.Where(user => user.Mail == context.UserName && user.Parola == pass).FirstOrDefault() != null)
                    {
                        if (db.Personeller.Where(per => per.Parola == pass).FirstOrDefault() != null)
                        {
                            ClaimsIdentity identity = new ClaimsIdentity(context.Options.AuthenticationType);
                            identity.AddClaim(new Claim("sub", context.UserName));
                            identity.AddClaim(new Claim("role", "user"));

                            context.Validated(identity);
                        }
                        else
                        {
                            context.SetError("Wrong Pass", "Parola hatalıdır.");
                        }
                    }
                    else
                    {
                        context.SetError("Not Found Employee", "Böyle bir personel kaydı bulunamadı.");
                    }
                }
            }
        }