Пример #1
0
        public ActionResult Create(User use, string num)
        {
            User s = db.User.SingleOrDefault(p => p.Uloginname == use.Uloginname);

            if (ModelState.IsValid)
            {
                if (s == null)
                {
                    if (num == "2")
                    {
                        db.User.Add(use);
                        db.SaveChanges();
                        return(RedirectToAction("Logon"));
                    }
                    else
                    {
                        return(Content("<script>alert('注册失败!');history.go(-1)</script>"));
                    }
                }
                else
                {
                    ModelState.AddModelError("flag", "改账号已存在");
                    return(View());
                }
            }
            else
            {
                return(Content("<script>alert('注册失败!');history.go(-1)</script>"));
            }
        }
Пример #2
0
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="com"></param>
        /// <returns></returns>
        public ActionResult AddCom(Comment com)
        {
            Comment com1 = db.Comment.Find(com.Cid);

            com1.Comments = com.Comments;
            com1.Ctime    = DateTime.Now;
            com1.Cstate   = 1;
            db.SaveChanges();
            return(RedirectToAction("UserComment", "Comment"));
        }
Пример #3
0
        /// <summary>
        /// 添加预约
        /// </summary>
        /// <param name="id"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public ActionResult Add(int?id, DateTime time)
        {
            //根据对应时间查询预约表的记录
            List <Appointment> App = db.Appointment.Where(p => p.Ttime == time).ToList();
            int num = App.Count();

            User      user = Session["user"] as User;
            Mediciner med  = db.Mediciner.Find(id);

            //查询对应时间、医生、用户对应的预约条数
            List <Appointment> App1 = db.Appointment.Where(p => (p.Mid == id) && (p.Uid == user.Uid) && (p.Atime == time)).ToList();
            int num1 = App1.Count();

            if (time > DateTime.Now)
            {
                //如果此时间段的预约条数小于医生设置的次数
                if (med.Mcount > num)
                {
                    //判断用户是否重复预约
                    if (num1 == 0)
                    {
                        Appointment app = new Appointment()
                        {
                            Mid    = med.Mid,
                            Uid    = user.Uid,
                            Atime  = time,
                            Ttime  = DateTime.Now,
                            Astate = 0,
                            Anun   = med.Mid,
                        };
                        db.Appointment.Add(app);
                        db.SaveChanges();
                        return(Content("<script>alert('预约成功!');history.go(-1)</script>"));
                    }
                    else
                    {
                        return(Content("<script>alert('此时间段您已经预约!');history.go(-1)</script>"));
                    }
                }
                else
                {
                    return(Content("<script>alert('此时间段已没有预约号!');history.go(-1)</script>"));
                }
            }
            else
            {
                return(Content("<script>alert('此时间段已失效!');history.go(-1)</script>"));
            }
        }
Пример #4
0
        public async Task <bool> UpdateAppointment(AppointmenTO filtro)
        {
            List <AppointmenTO> appointmentsByPacient = new List <AppointmenTO>();

            using (AppointmentsEntities dbContext = new AppointmentsEntities())
            {
                appointmentsByPacient = await(from app in dbContext.Appointments
                                              join pat in dbContext.Pacients on app.IdKeyPacient equals pat.IdKey
                                              where app.IdKeyPacient == filtro.IdKeyPacient &&
                                              app.IdKey == filtro.IdKey &&
                                              DbFunctions.DiffHours(app.Date, SqlFunctions.GetDate().Value) <= 24
                                              select app).ProjectTo <AppointmenTO>().ToListAsync();

                if (appointmentsByPacient.Count <= 0)
                {
                    Appointment AppointmentUpdate = Mapper.Map <Appointment>(filtro);
                    dbContext.Appointments.Attach(AppointmentUpdate);
                    var entry = dbContext.Entry(AppointmentUpdate);
                    entry.Property(e => e.IdState).IsModified = true;
                    // other changed properties
                    dbContext.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #5
0
        public async Task <bool> CreateAppointment(AppointmenTO filtro)
        {
            List <AppointmenTO> appointmentsByPacient = new List <AppointmenTO>();

            using (AppointmentsEntities dbContext = new AppointmentsEntities())
            {
                appointmentsByPacient = await(from app in dbContext.Appointments
                                              join pat in dbContext.Pacients on app.IdKeyPacient equals pat.IdKey
                                              join sta in dbContext.States on app.Type.IdKey equals sta.IdKey
                                              where app.IdKeyPacient == filtro.IdKeyPacient &&
                                              DbFunctions.TruncateTime(app.Date) == filtro.Date.Date &&
                                              sta.Description == "Programado"
                                              select app).ProjectTo <AppointmenTO>().ToListAsync();

                if (appointmentsByPacient.Count <= 0)
                {
                    Appointment AppointmentCreate = Mapper.Map <Appointment>(filtro);
                    dbContext.Appointments.Add(AppointmentCreate);
                    dbContext.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #6
0
        public ActionResult Create(Mediciner med)
        {
            Mediciner m = db.Mediciner.SingleOrDefault(p => p.Mloginname == med.Mloginname);

            if (ModelState.IsValid)
            {
                if (m == null)
                {
                    db.Mediciner.Add(med);
                    db.SaveChanges();
                    return(Content("<script>alert('注册成功!');history.go(-1)</script>"));
                }
                else
                {
                    return(Content("<script>alert('账号已存在!');history.go(-1)</script>"));
                }
            }
            else
            {
                return(Content("<script>alert('注册失败!');history.go(-1)</script>"));
            }
        }
Пример #7
0
 public void Save()
 {
     context.SaveChanges();
 }
Пример #8
0
        /// <summary>
        /// 冻结账号
        /// </summary>
        /// <returns></returns>
        public ActionResult Delete(int?id)
        {
            User sue = db.User.Find(id);

            sue.Ustate = 1;
            db.SaveChanges();
            return(RedirectToAction("UserH"));
        }