Esempio n. 1
0
        public JsonResult AddAppointments(AppointmentJsonObject json)
        {
            var         status         = "ok";
            var         actualdate     = json.date.Replace(@"\", string.Empty);
            Appointment newAppointment = new Appointment();

            if (json.appointmentId.HasValue)
            {
                newAppointment = context.Appointment.Find(json.appointmentId);
            }
            else
            {
                context.Appointment.Add(newAppointment);
            }
            using (var trans = new TransactionScope())
            {
                newAppointment.AppointmentDate = Convert.ToDateTime(actualdate);
                newAppointment.Description     = json.description;
                newAppointment.PetId           = Convert.ToInt32(json.petId);
                newAppointment.VeterinaryId    = json.veterinaryId;
                newAppointment.VetId           = json.vetId;
                newAppointment.Prescription    = json.prescription;
                newAppointment.Status          = json.status;
                context.SaveChanges();
                trans.Complete();
            }
            return(Json(new { status = status, appointement = newAppointment }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public static List <AppointmentJsonObject> from(List <Appointment> appointments)
        {
            List <AppointmentJsonObject> apjs = new List <AppointmentJsonObject>();

            foreach (var a in appointments)
            {
                apjs.Add(AppointmentJsonObject.from(a));
            }
            return(apjs);
        }
Esempio n. 3
0
        public static AppointmentJsonObject from(Appointment appointment)
        {
            AppointmentJsonObject apj = new AppointmentJsonObject();

            apj.appointmentId = appointment.AppointmentId;
            apj.vetId         = appointment.VetId;
            apj.veterinaryId  = appointment.VeterinaryId;
            apj.petId         = appointment.PetId;
            apj.date          = appointment.AppointmentDate.ToString();
            apj.description   = appointment.Description;
            apj.prescription  = appointment.Prescription;
            apj.vet           = appointment.Vet.Person.Name + " " + appointment.Vet.Person.LastName;
            apj.veterinary    = appointment.Veterinary.Name;
            apj.pet           = appointment.Pet.Name;
            return(apj);
        }
Esempio n. 4
0
 public JsonResult Appointments(Int32?petId)
 {
     if (petId.HasValue)
     {
         return(Json(new
         {
             status = "ok",
             content = AppointmentJsonObject.from(context.Appointment.Where(x => x.PetId == petId).ToList())
         }, JsonRequestBehavior.AllowGet
                     ));
     }
     else
     {
         return(Json(new
         {
             status = "ok",
             content = AppointmentJsonObject.from(context.Appointment.ToList())
         }, JsonRequestBehavior.AllowGet
                     ));
     }
     //return Json(appointmentId.HasValue ? AppointmentJsonObject.@from(context.Appointment.Where(x => x.AppointmentId == appointmentId).ToList()) : AppointmentJsonObject.@from(context.Appointment.ToList()), JsonRequestBehavior.AllowGet);
 }