Ejemplo n.º 1
0
        public int Add(d.Doctor newDoctor)
        {
            var entity = new Doctor
            {
                Username      = newDoctor.UserName,
                Pass          = newDoctor.PassWord,
                FirstName     = newDoctor.FirstName,
                LastName      = newDoctor.LastName,
                Email         = newDoctor.Email,
                City          = newDoctor.City.ToLower(),
                State         = newDoctor.State,
                Bio           = newDoctor.Bio,
                ExpYears      = newDoctor.Exp,
                Fee           = newDoctor.Fee,
                Phone         = newDoctor.Phone,
                Rating        = 0,
                Consultations = 0,
                DoctorType    = newDoctor.DoctorType
            };

            _context.Doctors.Add(entity);
            _context.SaveChanges();
            var doc     = _context.Doctors.First(d => d.Username == entity.Username);
            var cityTag = _context.Tags.First(t => t.term == doc.City.ToLower());
            var city    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = cityTag.tagId
            };
            var stateTag = _context.Tags.First(t => t.term == doc.State.ToLower());
            var state    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = stateTag.tagId
            };
            var typeTag = _context.Tags.First(t => t.term == doc.DoctorType.ToLower());
            var type    = new DoctorTag {
                doctorId = doc.DoctorId, tagId = typeTag.tagId
            };

            _context.DoctorTags.Add(city);
            _context.SaveChanges();
            _context.DoctorTags.Add(type);
            _context.SaveChanges();
            _context.DoctorTags.Add(state);
            _context.SaveChanges();
            return(entity.DoctorId);
        }
Ejemplo n.º 2
0
 public ActionResult CreateDoctor(DoctorTag doctorTag)
 {
     _repo.CreateDoctorTag(doctorTag);
     return(NoContent());
 }
Ejemplo n.º 3
0
 public void CreateDoctorTag(DoctorTag DoctorTag)
 {
     _context.DoctorTags.Add(DoctorTag);
     _context.SaveChanges();
 }