예제 #1
0
        public CustomerPingXiang UpdateSingle(int id, CustomerPingXiangReq data)
        {
            CustomerPingXiang model = db.CustomerPingXiang.Find(id);

            SetCustomerPingXiang(model, data);
            db.SaveChanges();
            return(model);
        }
예제 #2
0
 /// <summary>
 /// 设置model,如果不为空就设置,如果为空则和之前一样
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 /// <returns></returns>
 public CustomerPingXiang SetCustomerPingXiang(CustomerPingXiang model, CustomerPingXiangReq data)
 {
     if (data.KhId != null)
     {
         model.KhId = data.KhId.Value;
     }
     if (!string.IsNullOrEmpty(data.KhName))
     {
         model.KhName = data.KhName;
     }
     if (!string.IsNullOrEmpty(data.PingXiangName))
     {
         model.PingXiangName = data.PingXiangName;
     }
     if (!string.IsNullOrEmpty(data.GongXiao))
     {
         model.GongXiao = data.GongXiao;
     }
     if (data.EatStart != null && data.EatStart != DateTime.MinValue &&
         data.EatStart != SqlDateTime.MinValue.Value)
     {
         model.EatStart = data.EatStart.Value;
     }
     if (data.EatEnd != null && data.EatEnd != DateTime.MinValue && data.EatEnd != SqlDateTime.MinValue.Value)
     {
         model.EatEnd = data.EatEnd.Value;
     }
     if (!string.IsNullOrEmpty(data.PeiLiao))
     {
         model.PeiLiao = data.PeiLiao;
     }
     if (!string.IsNullOrEmpty(data.Desc))
     {
         model.Desc = data.Desc;
     }
     if (data.projectid != null)
     {
         model.ProjectId = data.projectid.Value;
     }
     if (!string.IsNullOrEmpty(data.ProjectName))
     {
         model.ProjectName = data.ProjectName;
     }
     if (!string.IsNullOrEmpty(data.ValidState))
     {
         model.ValidState = data.ValidState;
     }
     if (data.OptId != null)
     {
         model.OptId = data.OptId.Value;
     }
     if (!string.IsNullOrEmpty(data.OptName))
     {
         model.OptName = data.OptName;
     }
     if (data.CreateDate != null && data.CreateDate != DateTime.MinValue &&
         data.CreateDate != SqlDateTime.MinValue.Value)
     {
         model.CreateDate = data.CreateDate.Value;
     }
     if (data.RoomId != null)
     {
         model.RoomId = data.RoomId.Value;
     }
     if (!string.IsNullOrEmpty(data.RoomNumber))
     {
         model.RoomNumber = data.RoomNumber;
     }
     if (data.PingXiangId != null)
     {
         model.PingXiangId = data.PingXiangId.Value;
     }
     return(model);
 }