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 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 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 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));
            }
        }
        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;
                }
            }
        }
Ejemplo n.º 6
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));
            }
        }
Ejemplo n.º 7
0
        public HttpResponseMessage RegisterUser(User user)
        {
            if (db.Kullanicilar.FirstOrDefault(x => x.Mail == user.Email) == null)
            {
                string pass = Crypto.GetMd5Hash(MD5.Create(), user.Password);

                Kullanicilar u = new Kullanicilar()
                {
                    Ad                   = user.Name,
                    Soyad                = user.Surname,
                    CityId               = user.CityId,
                    District             = user.District,
                    DogumTarihi          = user.Birthday,
                    KanGrubuId           = user.BloodGroupId,
                    Mail                 = user.Email,
                    Parola               = pass,
                    SigaraAlkolKullanimi = user.UsingSmokingAndAlcohol,
                    TcKimlik             = user.IdentificationNo,
                    SonKanVermeTarihi    = user.LastBloodDonation,
                    Telefon              = user.Phone
                };

                db.Kullanicilar.Add(u);

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

                string user_bloodGroup = "";

                if (u.KanGrubuId != null)
                {
                    user_bloodGroup = db.KanGruplari.FirstOrDefault(x => x.Id == u.KanGrubuId).KanGrubu;
                }

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

                return(Request.CreateResponse(HttpStatusCode.Created, added_user));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Bu email ile daha önce kayıt olunmuştur."));
        }