Exemplo n.º 1
0
 public string Update(Adviser c)
 {
     YogaEntities ey = new YogaEntities();
     Adviser cc = ey.Adviser.FirstOrDefault((ccc) => ccc.Id == c.Id);
     if (cc == null) return string.Format("顾问为{0}的教练不存在", c.Id);
     cc.Position = c.Position;
     cc.Mobilephone = c.Mobilephone;
     cc.Name = c.Name;
     cc.UserId = c.UserId;
     return ey.SaveChanges() == 1 ? "成功" : "失败";
 }
Exemplo n.º 2
0
 public Adviser[] Search(Adviser c, ref int page, int pageSize, out int totalPages)
 {
     YogaEntities ey = new YogaEntities();
     var query = from cc in ey.Adviser where cc.Name.Contains(c.Name) && cc.Position.Contains(c.Position) select cc;
     if (c.Id > 0) query = query.Where((cc) => cc.Id == c.Id);
     if (c.UserId > 0) query = query.Where((cc) => cc.UserId == c.UserId);
     totalPages = (int)Math.Ceiling(query.Count() * 1.0 / pageSize);
     if (totalPages < 1)
     {
         page = 0;
         return null;
     }
     if (page == -1 || page > totalPages) page = totalPages;
     else if (page < 1) page = 1;
     return query.OrderBy((cc) => cc.Id).Skip((page - 1) * pageSize).Take(pageSize).ToArray();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Adviser object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="position">Initial value of the Position property.</param>
 /// <param name="mobilephone">Initial value of the Mobilephone property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 public static Adviser CreateAdviser(global::System.Int32 id, global::System.String name, global::System.String position, global::System.String mobilephone, global::System.Int32 userId)
 {
     Adviser adviser = new Adviser();
     adviser.Id = id;
     adviser.Name = name;
     adviser.Position = position;
     adviser.Mobilephone = mobilephone;
     adviser.UserId = userId;
     return adviser;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Adviser EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAdviser(Adviser adviser)
 {
     base.AddObject("Adviser", adviser);
 }
Exemplo n.º 5
0
 public string Add(Adviser a)
 {
     YogaEntities ey = new YogaEntities();
     ey.AddToAdviser(a);
     return ey.SaveChanges() == 1 ? "成功" : "失败";
 }