本文整理匯總了C#中Segator.Loms.Modules.Common.Entities.LomsContext類的典型用法代碼示例。如果您正苦於以下問題:C# LomsContext類的具體用法?C# LomsContext怎麽用?C# LomsContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LomsContext類屬於Segator.Loms.Modules.Common.Entities命名空間,在下文中一共展示了LomsContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetCitySuppliers
public IEnumerable<CitySupplierInfo> GetCitySuppliers(int cityId)
{
using (var db = new LomsContext())
{
var suppliers = from a in db.DispatchSuppliers.IncludeAll("Country", "State", "State.Country", "Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
join ac in db.DispatchSupplierCities on a.Id equals ac.SupplierId
where ac.CityId == cityId
orderby a.Name
select a;
var citySupplierInfos = new List<CitySupplierInfo>();
foreach (var supplier in suppliers.ToList())
{
if (supplier.CountryId != null && supplier.Country == null)
supplier.Country = db.Countries.SingleOrDefault(c => c.Id == supplier.CountryId);
else if (supplier.StateId != null && supplier.State == null)
supplier.State = db.States.Include("Country").SingleOrDefault(s => s.Id == supplier.StateId);
else if (supplier.SuburbId != null && supplier.Suburb == null)
supplier.Suburb = db.Suburbs.IncludeAll("State", "State.Country", "Country").SingleOrDefault(s => s.Id == supplier.SuburbId);
var info = new CitySupplierInfo() { Supplier = supplier };
info.Manager = db.DispatchSupplierUsers.FirstOrDefault(u => u.SupplierId == supplier.Id && u.RoleId == (int)SupplierUserRole.Manager);
var supplierCity = db.DispatchSupplierCities.IncludeAll("VehicleTypes", "VehicleTypes.VehicleType").SingleOrDefault(c => c.SupplierId == supplier.Id && c.CityId == cityId);
info.CityVehicleTypes = supplierCity.VehicleTypes;
citySupplierInfos.Add(info);
}
return citySupplierInfos;
}
}
示例2: GetWorldwide
public DispatchWorldwide GetWorldwide()
{
using (var db = new LomsContext())
{
return db.DispatchWorldwides.IncludeAll("Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country").FirstOrDefault();
}
}
示例3: GetAssociation
public Association GetAssociation()
{
using (var db = new LomsContext())
{
return db.Associations.SingleOrDefault(a => a.Id == CurrentAssociationId);
}
}
示例4: GetCreditCards
public IEnumerable<AssociationUserCreditCard> GetCreditCards(int profileId, SearchRequest searchRequest)
{
using (var db = new LomsContext())
{
var query = db.AssociationUserCreditCards.IncludeAll("Info")
.Where(a => a.AssociationUserId == profileId);
if (!string.IsNullOrWhiteSpace(searchRequest.SearchFilterValue))
{
if (searchRequest.SearchFilter == "Nickname")
query = from card in query
where card.Nickname.Contains(searchRequest.SearchFilterValue)
select card;
}
var cards = query.OrderBy(a => a.Nickname).ToList();
cards.ForEach(card =>
{
card.Number = ObfuscateCreditCardNumber(card.Info.Number);
card.Info = null;
card.AcceptChanges();
});
return cards;
}
}
示例5: GetRate
public static double GetRate(LomsContext db, Booking booking, DebugWriter debugInfoWriter)
{
double extras;
bool autoPending = false;
double price = 0.0;
try
{
price = GetBaseRateWithAdminFees(db, booking, debugInfoWriter, out autoPending, out extras);
if (price == 0.0 || autoPending)
return 0.0;
}
catch (Exception ex)
{
debugInfoWriter.WriteLine("Exception during GetBaseRateWithAdminFees!");
debugInfoWriter.WriteLine(ex.ToString());
return 0.0;
}
RateHelper.ApplyVehicleMargin(db, booking, debugInfoWriter, ref price);
price += extras;
RateHelper.ApplyHourZone(db, booking, debugInfoWriter, ref price);
//RateHelper.ApplyEventMargin(db, booking, debugInfoWriter, ref price, ref autoPending, ref eventName);
//if (autoPending)
// return 0.0;
return price;
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string guidStr = Page.RouteData.Values["guid"] as string;
Guid guid;
if (guidStr == null || !Guid.TryParseExact(guidStr, "D", out guid))
{
multiView1.SetActiveView(viewError);
lblError.Text = "Wrong reset guid!";
return;
}
else
{
using (var db = new LomsContext())
{
var pwdReset = db.AssociationUserPasswordResets.FirstOrDefault(a => a.Guid == guid);
if (pwdReset == null)
{
multiView1.SetActiveView(viewError);
lblError.Text = "Wrong reset guid!";
return;
}
var user = db.AssociationUsers.First(u => u.Id == pwdReset.AssociationUserId);
lblUserWelcome.Text = string.Format("Welcome, {0}.", user.FullName.ToUpper());
multiView1.SetActiveView(viewPwd);
}
}
}
}
示例7: GetCreditCards
public IEnumerable<AssociationUserCreditCard> GetCreditCards(int profileId, SearchRequest searchRequest)
{
using (var db = new LomsContext())
{
return GetCreditCards(db, profileId, searchRequest);
}
}
示例8: AllocateVehicle
public static bool AllocateVehicle(LomsContext db, Booking booking, bool isPhantom, StringBuilder debug)
{
int vehicleTypeId = booking.VehicleTypeId.Value;
var pickUpTime = booking.PickUpTime.Value;
int jorneyLength = 30; //min
DateTime fromDate = pickUpTime.Date;
DateTime toDate = pickUpTime.AddMinutes(jorneyLength).Date;
int fromTime = (((int)pickUpTime.TimeOfDay.TotalMinutes) / 30) * 30;
int toTime = (((int)pickUpTime.AddMinutes(jorneyLength).TimeOfDay.TotalMinutes) / 30) * 30;
if (!CheckAvailability(db, booking.Id, booking.CityId, vehicleTypeId, fromDate, toDate, fromTime, toTime, isPhantom, debug))
return false;
if (booking.AllocatedVehicle == null)
booking.AllocatedVehicle = new BookingAllocatedVehicle() { BookingId = booking.Id };
booking.AllocatedVehicle.CityId = booking.CityId;
booking.AllocatedVehicle.VehicleTypeId = vehicleTypeId;
booking.AllocatedVehicle.From = fromDate.AddMinutes(fromTime);
booking.AllocatedVehicle.To = toDate.AddMinutes(toTime);
booking.AllocatedVehicle.IsPhantom = isPhantom;
return true;
}
示例9: GetBooking
public Booking GetBooking(int id)
{
using (var db = new LomsContext())
{
return GetBooking(db, id);
}
}
示例10: SaveAddress
public AssociationUserAddress SaveAddress(AssociationUserAddress address)
{
try
{
using (var db = new LomsContext())
{
if (address.SuburbId != null)
{
address.Country = null;
address.State = null;
}
else if (address.StateId != null)
address.Country = null;
db.AssociationUserAddresses.ApplyChanges(address);
db.SaveChanges();
return db.AssociationUserAddresses.IncludeAll("Country", "State", "State.Country", "Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
.FirstOrDefault(a => a.Id == address.Id);
}
}
catch (Exception ex)
{
address.AddError("Error", ex.Message);
return address;
}
}
示例11: SaveWorldwideUser
public DispatchUser SaveWorldwideUser(DispatchUser user, byte[] imageBytes, bool deleteImage)
{
int managerId = int.Parse(((FormsIdentity)(HttpContext.Current.User.Identity)).Ticket.UserData);
using (var scope = new TransactionScope())
using (var db = new LomsContext())
{
if (user.Id == 0)
{
user.Login = user.FirstName[0] + user.LastName;
var staffManager = (from m in db.DispatchUsers
where m.Id == managerId
select m).Single();
user.CreatedBy = staffManager.FirstName + " " + staffManager.LastName;
user.CreatedDate = DateTime.UtcNow;
}
if (user.Id == 0)
{
if (user.Id == 0 && string.IsNullOrEmpty(user.Pwd))
user.Pwd = "123456!";
MembershipCreateStatus ret;
MembershipUser membershipUser = Membership.CreateUser(user.Login, user.Pwd, user.Email, "Who am I?", "I", true, null, out ret);
if (ret != MembershipCreateStatus.Success)
throw new ApplicationException(ret.ToString());
user.AspNetUserId = (Guid)membershipUser.ProviderUserKey;
}
else if (!string.IsNullOrEmpty(user.Pwd))
{
MembershipUser membershipUser = Membership.GetUser(user.Login);
string tempPwd = membershipUser.ResetPassword();
membershipUser.ChangePassword(tempPwd, user.Pwd);
}
if (!Roles.IsUserInRole(user.Login, RoleName.DispatchUser))
Roles.AddUserToRole(user.Login, RoleName.DispatchUser);
if (user.Role == DispatchUserRole.Manager && !Roles.IsUserInRole(user.Login, RoleName.DispatchManager))
Roles.AddUserToRole(user.Login, RoleName.DispatchManager);
else if (user.Role != DispatchUserRole.Manager && Roles.IsUserInRole(user.Login, RoleName.DispatchManager))
Roles.RemoveUserFromRole(user.Login, RoleName.DispatchManager);
db.DispatchUsers.ApplyChanges(user);
db.SaveChanges();
user = db.DispatchUsers.IncludeAll("Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
.FirstOrDefault(a => a.Id == user.Id);
scope.Complete();
return user;
}
}
示例12: GetAssociationName
public string GetAssociationName()
{
using (var db = new LomsContext())
{
return (from a in db.Associations
where a.Id == CurrentAssociationId
select a.Name).FirstOrDefault();
}
}
示例13: GetCurrentAssociation
public Association GetCurrentAssociation()
{
var associationId = (int)HttpContext.Current.Items["AssociationId"];
using (var db = new LomsContext())
{
var association = db.Associations.Include("Country").FirstOrDefault(a => a.Id == associationId);
return association;
}
}
示例14: GetWorldwideUsers
public IEnumerable<DispatchUser> GetWorldwideUsers()
{
using (var db = new LomsContext())
{
return db.DispatchUsers.IncludeAll("Country", "Suburb", "Suburb.Country", "Suburb.State", "Suburb.State.Country")
.Where(u => u.RegionId == null && u.DistrictId == null)
.ToList();
}
}
示例15: GetUser
public AssociationUser GetUser()
{
using (var db = new LomsContext())
{
int currentUserId = CurrentUserId();
var user = db.AssociationUsers.IncludeAll("Country").FirstOrDefault(u => u.Id == currentUserId);
return user;
}
}