public RoomCheckIn UpdateSingle(int id, RoomCheckInReq data) { RoomCheckIn model = db.RoomCheckIn.Find(id); SetRoomCheckIn(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public RoomCheckIn SetRoomCheckIn(RoomCheckIn model, RoomCheckInReq data) { if (data.RoomId != null) { model.RoomId = data.RoomId.Value; } if (data.StartDate != null && data.StartDate != DateTime.MinValue && data.StartDate != SqlDateTime.MinValue.Value) { model.StartDate = data.StartDate.Value; } if (data.EndDate != null && data.EndDate != DateTime.MinValue && data.EndDate != SqlDateTime.MinValue.Value) { model.EndDate = data.EndDate.Value; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (data.KeHuId != null) { model.KeHuId = data.KeHuId.Value; } if (!string.IsNullOrEmpty(data.KeHuName)) { model.KeHuName = data.KeHuName; } if (!string.IsNullOrEmpty(data.RoomDesc)) { model.RoomDesc = data.RoomDesc; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.OptId != null) { model.OptId = data.OptId.Value; } if (data.CreateDate != null && data.CreateDate != DateTime.MinValue && data.CreateDate != SqlDateTime.MinValue.Value) { model.CreateDate = data.CreateDate.Value; } if (!string.IsNullOrEmpty(data.Remark)) { model.Remark = data.Remark; } if (data.FloorId != null) { model.FloorId = data.FloorId.Value; } if (!string.IsNullOrEmpty(data.SwitchRoomTag)) { model.SwitchRoomTag = data.SwitchRoomTag; } if (data.PreRoomCheckInId != null) { model.PreRoomCheckInId = data.PreRoomCheckInId.Value; } if (data.InitialHeTongId != null) { model.InitialHeTongId = data.InitialHeTongId.Value; } if (!string.IsNullOrEmpty(data.SwitchRoomDesc)) { model.SwitchRoomDesc = data.SwitchRoomDesc; } return(model); }