예제 #1
0
        public ObjectResult Put(string id, [FromForm] WebAPIEvent apiEvent)
        {
            var i            = (ClaimsIdentity)User.Identity;
            var updatedEvent = (CitaOdontologica)apiEvent;
            var dbEvent      = _context.CitaOdontologica.Find(id);

            //dbEvent.CodigoPaciente = updatedEvent.CodigoPaciente;
            dbEvent.CodigoPaciente       = updatedEvent.CodigoPaciente;
            dbEvent.CodigoPersonal       = updatedEvent.CodigoPersonal;
            dbEvent.FechaCreacion        = Funciones.ObtenerFechaActual("SA Pacific Standard Time");
            dbEvent.Observaciones        = updatedEvent.Observaciones;
            dbEvent.FechaInicio          = Convert.ToDateTime(updatedEvent.FechaInicio);
            dbEvent.FechaFin             = Convert.ToDateTime(updatedEvent.FechaFin);
            dbEvent.HoraInicio           = new TimeSpan(updatedEvent.FechaInicio.Hour, updatedEvent.FechaInicio.Minute, updatedEvent.FechaInicio.Second);
            dbEvent.HoraFin              = new TimeSpan(updatedEvent.FechaFin.Hour, updatedEvent.FechaFin.Minute, updatedEvent.FechaFin.Second);
            dbEvent.Estado               = "M";
            dbEvent.UsuarioCreacion      = i.Name;
            dbEvent.RegistroRecetaMedica = false;

            _context.SaveChanges();

            return(Ok(new
            {
                action = "updated"
            }));
        }
예제 #2
0
        public ObjectResult Put(int id, [FromForm] WebAPIEvent apiEvent)
        {
            var updatedEvent = (SchedulerEvent)apiEvent;
            var dbEvent      = _context.Event.Find(id);

            dbEvent.Title       = updatedEvent.Title;
            dbEvent.Description = updatedEvent.Description;
            dbEvent.StartDate   = updatedEvent.StartDate;
            dbEvent.EndDate     = updatedEvent.EndDate;
            dbEvent.Venue       = updatedEvent.Venue;
            dbEvent.Type        = updatedEvent.Type;
            dbEvent.Category    = updatedEvent.Category;
            dbEvent.EventPID    = updatedEvent.EventPID;
            dbEvent.RecType     = updatedEvent.RecType;
            dbEvent.EventLength = updatedEvent.EventLength;
            _context.SaveChanges();

            if (!string.IsNullOrEmpty(updatedEvent.RecType) && updatedEvent.RecType != "none")
            {
                //all modified occurrences must be deleted when we update a recurring series
                //https://docs.dhtmlx.com/scheduler/server_integration.html#recurringevents

                _context.Event.RemoveRange(
                    _context.Event.Where(e => e.EventPID == id)
                    );
            }

            _context.SaveChanges();

            return(Ok(new
            {
                action = "updated"
            }));
        }
예제 #3
0
        public ObjectResult Post([FromForm] WebAPIEvent apiEvent)
        {
            var newEvent = (SchedulerEvent)apiEvent;

            _context.Events.Add(newEvent);
            _context.SaveChanges();

            return(Ok(new
            {
                tid = newEvent.Id,
                action = "inserted"
            }));
        }
예제 #4
0
        public IHttpActionResult CreateSchedulerEvent(WebAPIEvent webAPIEvent)
        {
            var newSchedulerEvent = (SchedulerEvent)webAPIEvent;

            db.SchedulerEvents.Add(newSchedulerEvent);
            db.SaveChanges();

            return(Ok(new
            {
                tid = newSchedulerEvent.Id,
                action = "inserted"
            }));
        }
예제 #5
0
        public IHttpActionResult EditSchedulerEvent(int id, WebAPIEvent webAPIEvent)
        {
            var updatedSchedulerEvent = (SchedulerEvent)webAPIEvent;

            updatedSchedulerEvent.Id = id;
            db.Entry(updatedSchedulerEvent).State = EntityState.Modified;
            db.SaveChanges();

            return(Ok(new
            {
                action = "updated"
            }));
        }
예제 #6
0
        public ObjectResult Put(int id, [FromForm] WebAPIEvent apiEvent)
        {
            var updatedEvent = (SchedulerEvent)apiEvent;
            var dbEvent      = _context.Events.Find(id);

            dbEvent.Name      = updatedEvent.Name;
            dbEvent.StartDate = updatedEvent.StartDate;
            dbEvent.EndDate   = updatedEvent.EndDate;
            _context.SaveChanges();

            return(Ok(new
            {
                action = "updated"
            }));
        }
        public IHttpActionResult CreateSchedulerEvent(WebAPIEvent webAPIEvent)
        {
            var Creator           = User.Identity.GetUserId();
            var newSchedulerEvent = (SchedulerEvent)webAPIEvent;

            newSchedulerEvent.Creator = Creator;

            db.SchedulerEvents.Add(newSchedulerEvent);
            db.SaveChanges();

            return(Ok(new
            {
                tid = newSchedulerEvent.Id,
                action = "inserted"
            }));
        }
예제 #8
0
        public ObjectResult Post([FromForm] WebAPIEvent apiEvent)
        {
            var   newEvent  = (CitaOdontologica)apiEvent;
            var   i         = (ClaimsIdentity)User.Identity;
            Int64 maxCodigo = 0;

            maxCodigo                     = Convert.ToInt64(_context.CitaOdontologica.Max(f => f.Codigo));
            maxCodigo                    += 1;
            newEvent.Codigo               = maxCodigo.ToString("D8");
            newEvent.CodigoPaciente       = apiEvent.paciente;
            newEvent.CodigoPersonal       = apiEvent.doctor;
            newEvent.FechaCreacion        = Funciones.ObtenerFechaActual("SA Pacific Standard Time");
            newEvent.Observaciones        = apiEvent.observaciones;
            newEvent.FechaInicio          = Convert.ToDateTime(apiEvent.start_date);
            newEvent.FechaFin             = Convert.ToDateTime(apiEvent.end_date); //Convert.ToDateTime(apiEvent.end_date);
            newEvent.HoraInicio           = new TimeSpan(newEvent.FechaInicio.Hour, newEvent.FechaInicio.Minute, newEvent.FechaInicio.Second);
            newEvent.HoraFin              = new TimeSpan(newEvent.FechaFin.Hour, newEvent.FechaFin.Minute, newEvent.FechaFin.Second);
            newEvent.Estado               = "C";
            newEvent.UsuarioCreacion      = i.Name;
            newEvent.RegistroRecetaMedica = false;
            _context.CitaOdontologica.Add(newEvent);
            _context.SaveChanges();

            //enviar el mail

            PlantillaCorreoElectronico correo = new PlantillaCorreoElectronico();

            correo = _context.PlantillaCorreoElectronico.SingleOrDefault(p => p.Asunto.Contains("Cita"));
            var paciente  = _context.Paciente.Where(p => p.Codigo == apiEvent.paciente).FirstOrDefault();
            var doctor    = _context.Personal.Where(d => d.Codigo == apiEvent.doctor).FirstOrDefault();
            var soloFecha = (newEvent.FechaInicio.ToString("dd/MM/yyyy")); ///Convert.ToDateTime(newEvent.FechaInicio.ToString("dd/MM/yyyy"));
            //var fechaLarga = soloFecha.ToLongDateString();
            var hora = newEvent.FechaInicio.ToString("HH:mm");             // newEvent.FechaInicio.TimeOfDay.ToString();//newEvent.FechaInicio.Hour.ToString() + ":" + newEvent.FechaInicio.Minute.ToString();//newEvent.FechaInicio.ToString("hh:mm");

            //envio del email
            string cuerpo = FuncionesEmail.AsuntoCitaOdontologica(correo.Cuerpo,
                                                                  paciente.NombreCompleto, soloFecha, hora, doctor.NombreCompleto);

            var correoMensaje = FuncionesEmail.EnviarEmail(_emailSender, paciente.MailEpn + ',' + paciente.MailPersonal, correo.Asunto, cuerpo);


            return(Ok(new
            {
                tid = newEvent.Codigo,
                action = "inserted"
            }));
        }
        public IHttpActionResult EditSchedulerEvent(int id, WebAPIEvent webAPIEvent)
        {
            var updatedSchedulerEvent = (SchedulerEvent)webAPIEvent;

            updatedSchedulerEvent.Id = id;

            if (updatedSchedulerEvent.Creator.Equals(User.Identity.GetUserId()) || User.IsInRole("Admin"))
            {
                db.Entry(updatedSchedulerEvent).State = EntityState.Modified;
                db.SaveChanges();
            }

            else
            {
                return(Ok(new
                {
                    action = "failed" + updatedSchedulerEvent.Creator
                }));
            }
            return(Ok(new
            {
                action = "updated"
            }));
        }
예제 #10
0
        public ObjectResult Post([FromForm] WebAPIEvent apiEvent)
        {
            var newEvent = (SchedulerEvent)apiEvent;

            _context.Event.Add(newEvent);
            _context.SaveChanges();

            var ev = _context.Event.Find(newEvent.Id);

            if ((ev.Id == newEvent.Id) && (newEvent.Type == "Startup"))
            {
                string    select = "SELECT * FROM Users WHERE UserRole='Startup'";
                DataTable dt     = DBUtl.GetTable(select);

                foreach (DataRow row in dt.Rows)
                {
                    string fname    = row.Field <string>("FullName");
                    string email    = row.Field <string>("Email");
                    string template = @"Hi {0},<br/><br/>
                               You are invited to the event - <b>{1}</b><br/><br/>
                               Start Date and Time  : <b>{2}</b><br/><br/>
                               End Date and Time    : <b>{3}</b><br/><br/>";
                    string title    = "Invitation to Attend Program";
                    string message  = String.Format(template, fname, newEvent.Title, newEvent.StartDate, newEvent.EndDate);
                    string result;
                    EmailUtl.SendEmail(email, title, message, out result);
                }
            }
            else if ((ev.Id == newEvent.Id) && (newEvent.Type == "Alumni"))
            {
                string    select = "SELECT * FROM Users WHERE UserRole='Alumni'";
                DataTable dt     = DBUtl.GetTable(select);

                foreach (DataRow row in dt.Rows)
                {
                    string fname    = row.Field <string>("FullName");
                    string email    = row.Field <string>("Email");
                    string template = @"Hi {0},<br/><br/>
                               You are invited to the event - <b>{1}</b><br/><br/>
                               Start Date and Time  : <b>{2}</b><br/><br/>
                               End Date and Time    : <b>{3}</b><br/><br/>
                               Venue                : <b>{4}</b>";
                    string title    = "Invitation to Attend Program";
                    string message  = String.Format(template, fname, newEvent.Title, newEvent.StartDate, newEvent.EndDate, newEvent.Venue);
                    string result;
                    EmailUtl.SendEmail(email, title, message, out result);
                }
            }
            else if ((ev.Id == newEvent.Id) && (newEvent.Type == "Both"))
            {
                string    select = "SELECT * FROM Users WHERE UserRole='Startup' AND UserRole='Alumni'";
                DataTable dt     = DBUtl.GetTable(select);

                foreach (DataRow row in dt.Rows)
                {
                    string fname    = row.Field <string>("FullName");
                    string email    = row.Field <string>("Email");
                    string template = @"Hi {0},<br/><br/>
                               You are invited to the event - <b>{1}</b><br/><br/>
                               Start Date and Time  : <b>{2}</b><br/><br/>
                               End Date and Time    : <b>{3}</b><br/><br/>";
                    string title    = "Invitation to Attend Program";
                    string message  = String.Format(template, fname, newEvent.Title, newEvent.StartDate, newEvent.EndDate);
                    string result;
                    EmailUtl.SendEmail(email, title, message, out result);
                }
            }

            // delete a single occurrence from a recurring series
            var resultAction = "inserted";

            if (newEvent.RecType == "none")
            {
                resultAction = "deleted";
            }

            return(Ok(new
            {
                tid = newEvent.Id,
                action = resultAction
            }));
        }