//Update a record public static int UpdateRecord(etblPropertySpaMap eobj, bool Type) { int retval = 0; using (OneFineRateEntities dbnew = new OneFineRateEntities()) { try { OneFineRate.tblPropertySpaMap obj = (OneFineRate.tblPropertySpaMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertySpaMap()); if (Type) { dbnew.tblPropertySpaMaps.Attach(obj); dbnew.Entry(obj).State = System.Data.Entity.EntityState.Modified; dbnew.SaveChanges(); retval = 1; } else { dbnew.tblPropertySpaMaps.Add(obj); dbnew.SaveChanges(); retval = 1; } } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(int PropId, int Channelmgr, int user) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var obj = db.tblPropertyChannelMgrMaps.SingleOrDefault(u => u.iPropId == PropId); if (obj != null) { db.tblPropertyChannelMgrMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } tblPropertyChannelMgrMap CM = new tblPropertyChannelMgrMap(); CM.dtActionDate = DateTime.Now; CM.iActionBy = user; CM.iChannelMgr = Channelmgr; CM.iPropId = PropId; db.tblPropertyChannelMgrMaps.Attach(CM); db.Entry(CM).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(eUsers eobj, string Groups) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblUserM dbuser = (OneFineRate.tblUserM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblUserM()); var dbobj = db.tblUserMs.SingleOrDefault(u => u.sUserName == dbuser.sUserName); if (dbobj != null) { return(2); } dbobj = db.tblUserMs.SingleOrDefault(u => u.sEmail == dbuser.sEmail); if (dbobj != null) { return(3); } db.tblUserMs.Add(dbuser); db.SaveChanges(); try { var obj = db.tblUserGroupMs.Where(u => u.iUserId == dbuser.iUserId); db.tblUserGroupMs.RemoveRange(obj); } catch (Exception) { } var grps = Groups.Split(',').ToList(); db.tblUserGroupMs.AddRange(grps.Select(x => new tblUserGroupM() { cStatus = "A", dtActionDate = DateTime.Now, dtCreationDate = DateTime.Now, iActionBy = dbuser.iActionBy, iCreatedBy = dbuser.iActionBy, iGroupId = Convert.ToInt32(x), iUserId = dbuser.iUserId })); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(etblPropertyRoomTypeRoomAmentiesMap eobj) { bool Type = false; int retval = 0; using (OneFineRateEntities dbnew = new OneFineRateEntities()) { try { var dbobj = dbnew.tblPropertyRoomTypeRoomAmentiesMaps.SingleOrDefault(u => u.iPropId == eobj.iPropId && u.iRoomId == eobj.iRoomId); if (dbobj != null) { Type = true; } } catch (Exception) { throw; } } using (OneFineRateEntities db = new OneFineRateEntities()) { try { if (Type) { OneFineRate.tblPropertyRoomTypeRoomAmentiesMap obj = (OneFineRate.tblPropertyRoomTypeRoomAmentiesMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyRoomTypeRoomAmentiesMap()); db.tblPropertyRoomTypeRoomAmentiesMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); db.uspUpdateAmenitiesInLookup(eobj.iPropId, eobj.iRoomId); retval = 1; } else { OneFineRate.tblPropertyRoomTypeRoomAmentiesMap dbuser = (OneFineRate.tblPropertyRoomTypeRoomAmentiesMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyRoomTypeRoomAmentiesMap()); db.tblPropertyRoomTypeRoomAmentiesMaps.Add(dbuser); db.SaveChanges(); db.uspUpdateAmenitiesInLookup(eobj.iPropId, eobj.iRoomId); retval = 1; } } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(eGroups eobj, string Menus) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblGroupM dbGroup = (OneFineRate.tblGroupM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblGroupM()); var dbobj = db.tblGroupMs.SingleOrDefault(u => u.sGroupName == dbGroup.sGroupName); if (dbobj != null) { return(2); } else { var mns = Menus.Split(',').ToList(); if (mns[0] != "") { db.tblGroupMs.Add(dbGroup); db.SaveChanges(); db.tblGroupMenuMs.AddRange(mns.Select(menu => new tblGroupMenuM { cStatus = "A", dtActionDate = DateTime.Now, dtCreationDate = DateTime.Now, iActionBy = dbGroup.iActionBy, iCreatedBy = dbGroup.iActionBy, iMenuId = Convert.ToInt32(menu), iGroupId = dbGroup.iGroupId })); db.SaveChanges(); retval = 1; } else { retval = 2; } } } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(eGroups eobj, string Menus) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var mns = Menus.Split(',').ToList(); if (mns.Count > 1) { OneFineRate.tblGroupM obj = (OneFineRate.tblGroupM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblGroupM()); db.tblGroupMs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); try { var obj1 = db.tblGroupMenuMs.Where(u => u.iGroupId == obj.iGroupId); db.tblGroupMenuMs.RemoveRange(obj1); } catch (Exception) { } db.tblGroupMenuMs.AddRange(mns.Select(menu => new tblGroupMenuM { cStatus = "A", dtActionDate = DateTime.Now, dtCreationDate = DateTime.Now, iActionBy = obj.iActionBy, iCreatedBy = obj.iActionBy, iMenuId = Convert.ToInt32(menu), iGroupId = obj.iGroupId })); db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(eCustomerPointsMap eobj) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblCustomerPointsMap obj = (OneFineRate.tblCustomerPointsMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblCustomerPointsMap()); db.tblCustomerPointsMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw e; } catch (Exception ex) { throw ex; } } }
//Update Rank public static int UpdateRecord(etblRankManagement eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { bool checkExists = false; checkExists = db.tblRankManagements.Any( p => p.iPropId == eobj.iPropId && p.iID != eobj.iID && (((p.dtStartdate <= eobj.dtStartdate && p.dtEndDate >= eobj.dtStartdate) || (p.dtStartdate <= eobj.dtEndDate && p.dtEndDate >= eobj.dtEndDate)) || ((eobj.dtStartdate <= p.dtStartdate && eobj.dtEndDate >= p.dtStartdate) || (eobj.dtStartdate <= p.dtEndDate && eobj.dtEndDate >= p.dtEndDate))) ); if (checkExists != true) { OneFineRate.tblRankManagement obj = (OneFineRate.tblRankManagement)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblRankManagement()); db.tblRankManagements.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(etblPropertyDiningMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblPropertyDiningMap obj = (OneFineRate.tblPropertyDiningMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyDiningMap()); db.tblPropertyDiningMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; //var checkExistsRestaurantName = db.tblPropertyDiningMaps.Any( // p => p.iPropId == eobj.iPropId // && p.iRestaurantID != eobj.iRestaurantID // && p.sRestaurantName == eobj.sRestaurantName); //if (checkExistsRestaurantName == false) //{ //} //else //{ // retval = 2; //} } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(etblPropertyDiningMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var checkExistsRestaurantName = db.tblPropertyDiningMaps.Any( p => p.iPropId == eobj.iPropId && p.sRestaurantName == eobj.sRestaurantName); if (checkExistsRestaurantName == false) { OneFineRate.tblPropertyDiningMap dbstate = (OneFineRate.tblPropertyDiningMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyDiningMap()); db.tblPropertyDiningMaps.Add(dbstate); db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
public static KeyValuePair <int, string> ToggleStatus(int companyId, bool enable) { using (OneFineRateEntities db = new OneFineRateEntities()) { var comp = db.tblCorporateCompanyMs.Where(x => x.iCompanyId == companyId).FirstOrDefault(); if (comp != null) { if (enable) { comp.cStatus = "A"; } else { comp.cStatus = "I"; } db.tblCorporateCompanyMs.Attach(comp); db.Entry(comp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(new KeyValuePair <int, string>(1, "Record has been updated successfully!")); } return(new KeyValuePair <int, string>(-1, "An error occured while updating the record.")); } }
//Delete a record public static int DeleteRecord(etblPropertyPromotionMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { using (OneFineRateEntities db1 = new OneFineRateEntities()) { var PP = db1.tblPropertyPromotionMaps.Where(a => a.iID == eobj.iID).ToList(); if (eobj.iPromoId != Convert.ToInt32(Promotions.OFRFreebies)) { eobj.bParentActive = (bool)PP[0].bParentActive; } eobj.iPromoId = PP[0].iPromoId; } OneFineRate.tblPropertyPromotionMap obj = (OneFineRate.tblPropertyPromotionMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyPromotionMap()); db.tblPropertyPromotionMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Add new record public static int AddRecord(eMacroAreaM eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblMacroAreaMs.Where(u => u.iCountryId == eobj.iCountryId && u.iStateId == eobj.iStateId && u.iCityId == eobj.iCityId && u.sArea == eobj.sArea.Trim()) select new { s.iAreaId, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblMacroAreaM dbstate = (OneFineRate.tblMacroAreaM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblMacroAreaM()); db.tblMacroAreaMs.Add(dbstate); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
public static KeyValuePair <int, string> ToggleStatus(int RateRangeId, bool enable) { try { using (OneFineRateEntities db = new OneFineRateEntities()) { var comp = db.tblRoomRateRangeMs.Where(x => x.iRangeId == RateRangeId).FirstOrDefault(); if (comp != null) { if (enable) { comp.cStatus = "A"; } else { comp.cStatus = "I"; } db.Entry(comp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(new KeyValuePair <int, string>(1, "Status updated successfully!")); } return(new KeyValuePair <int, string>(-1, "An error occured while updating the record.")); } } catch (Exception) { return(new KeyValuePair <int, string>(-1, "An error occured while updating the record.")); } }
public static int AddRecord(etblHotelPartnerM eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var checkExists = db.tblHotelPartnerMs.Any( p => p.sHotelName == eobj.sHotelName && p.sEmail == eobj.sEmail); if (checkExists == false) { OneFineRate.tblHotelPartnerM dbuser = (OneFineRate.tblHotelPartnerM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblHotelPartnerM()); db.tblHotelPartnerMs.Add(dbuser); db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
//Add a record to guest details table public static int AddRecord(eBiddingSearch eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { GuestUserDetails objDetail = new GuestUserDetails(); objDetail.Title = eobj.sUserTitle; objDetail.FirstName = eobj.sUserFirstName; objDetail.LastName = eobj.sUserLastName; objDetail.Email = eobj.sUserEmail; objDetail.PhoneNumber = eobj.sUserMobileNo; OneFineRate.tblWebsiteGuestUserMaster dbuser = (OneFineRate.tblWebsiteGuestUserMaster)OneFineRateAppUtil.clsUtils.ConvertToObject(objDetail, new OneFineRate.tblWebsiteGuestUserMaster()); db.tblWebsiteGuestUserMasters.Add(dbuser); db.SaveChanges(); retval = Convert.ToInt32(dbuser.Id); } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(etblPropertyRoomMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var CheckRoomCodeExists = db.tblPropertyRoomMaps.Any( p => p.iPropId == eobj.iPropId && p.iRoomId != eobj.iRoomId && p.sRoomCode == eobj.sRoomCode); if (CheckRoomCodeExists == false) { OneFineRate.tblPropertyRoomMap obj = (OneFineRate.tblPropertyRoomMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyRoomMap()); db.tblPropertyRoomMaps.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } else { retval = 2; } } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(eTblPromotionalHotel eobj) { int retval = -1; using (OneFineRateEntities db = new OneFineRateEntities()) { try { var existingModel = db.tblPromotionalHotelsMs.FirstOrDefault(x => x.sPosition == eobj.sPosition); if (existingModel != null) { existingModel.iPropId = eobj.iPropId; existingModel.sDescription = eobj.sDescription; existingModel.sImageUrl = eobj.sImageUrl; existingModel.iActionBy = eobj.iActionBy; existingModel.dtActionDate = eobj.dtActionDate; existingModel.sPosition = eobj.sPosition; } //db.Entry(existingModel).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(etblPropertyRoomRatePlanInventoryMap eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { //remove old mapings db.tblPropertyRoomRatePlanInventoryMaps.RemoveRange(db.tblPropertyRoomRatePlanInventoryMaps.Where(x => x.iRoomId == eobj.iRoomId && x.dtInventoryDate == eobj.dtInventoryDate && x.iRPId == eobj.iRPId)); OneFineRate.tblPropertyRoomRatePlanInventoryMap obj = (OneFineRate.tblPropertyRoomRatePlanInventoryMap)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPropertyRoomRatePlanInventoryMap()); db.tblPropertyRoomRatePlanInventoryMaps.Add(obj); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
public static int AddMultipleRecord(etblPropetyPhotoMap[] eobjs) { int statusCode = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { foreach (var item in eobjs) { item.iPhotoCatId = null; item.iPhotoSubCatId = null; OneFineRate.tblPropertyPhotoMap dbPropertyImg = (OneFineRate.tblPropertyPhotoMap)OneFineRateAppUtil.clsUtils.ConvertToObject(item, new OneFineRate.tblPropertyPhotoMap()); db.tblPropertyPhotoMaps.Add(dbPropertyImg); } statusCode = db.SaveChanges(); } catch (Exception) { throw; } } return(statusCode); }
//Add new record public static int AddRecord(eRatePlan eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblRatePlanMs.Where(u => u.sRatePlan == eobj.sRatePlan.Trim()) select new { s.iRatePlanId, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblRatePlanM dbuser = (OneFineRate.tblRatePlanM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblRatePlanM()); db.tblRatePlanMs.Add(dbuser); db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
//Update a record public static int UpdateRecord(eRatePlan eobj) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { int dbobj = (from s in db.tblRatePlanMs.Where(u => u.sRatePlan == eobj.sRatePlan.Trim() && u.iRatePlanId != eobj.iRatePlanId) select new { s.iRatePlanId, }).Count(); if (dbobj > 0) { return(retval = 2); } OneFineRate.tblRatePlanM obj = (OneFineRate.tblRatePlanM)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblRatePlanM()); db.tblRatePlanMs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
public static int UpdateRecord(eTblPurchaseHistory eobj) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblPurchaseHistory obj = (OneFineRate.tblPurchaseHistory)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPurchaseHistory()); db.tblPurchaseHistories.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } throw; } catch (Exception) { throw; } } }
public static long AddRecordAndGetId(eTblPurchaseHistory eobj) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblPurchaseHistory purchangeHistory = (OneFineRate.tblPurchaseHistory)OneFineRateAppUtil.clsUtils.ConvertToObject(eobj, new OneFineRate.tblPurchaseHistory()); db.tblPurchaseHistories.Add(purchangeHistory); var status = db.SaveChanges(); return(purchangeHistory.iPurchaseId); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } throw; } catch (Exception) { throw; } } }
//Delete a record public static int DeleteRecord(int id) { int retval = 0; using (OneFineRateEntities db = new OneFineRateEntities()) { try { try { var obj1 = db.tblGroupMenuMs.Where(u => u.iGroupId == id); db.tblGroupMenuMs.RemoveRange(obj1); } catch (Exception) { } try { var obj1 = db.tblUserGroupMs.Where(u => u.iUserId == id); db.tblUserGroupMs.RemoveRange(obj1); } catch (Exception) { } var obj = db.tblGroupMs.SingleOrDefault(u => u.iGroupId == id); db.tblGroupMs.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); retval = 1; } catch (Exception) { throw; } } return(retval); }
public static bool UpdateEmailVerified(long userId) { using (OneFineRateEntities db = new OneFineRateEntities()) { db.tblWebsiteUserMaters.Where(user => user.Id == userId).SingleOrDefault().EmailConfirmed = true; return(db.SaveChanges() > 0); } }
public void Update(TUser user) { using (var db = new OneFineRateEntities()) { var tblUser = (tblWebsiteUserMater)OneFineRateAppUtil.clsUtils.ConvertToObject(user, new tblWebsiteUserMater()); db.tblWebsiteUserMaters.Attach(tblUser); db.Entry(tblUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public void Insert(TUser user) { using (var db = new OneFineRateEntities()) { var tblUser = (tblWebsiteUserMater)OneFineRateAppUtil.clsUtils.ConvertToObject(user, new tblWebsiteUserMater()); db.tblWebsiteUserMaters.Add(tblUser); db.SaveChanges(); } }
public void Delete(TUser user, Claim claim) { var tblClaim = new tblWebsiteUserClaim() { ClaimType = claim.Type, ClaimValue = claim.Value, UserId = user.Id }; using (OneFineRateEntities db = new OneFineRateEntities()) { db.tblWebsiteUserClaims.Add(tblClaim); db.SaveChanges(); } }
//Add new record public static int AddRecord(eCustomerPointsMap customerPointsMap) { using (OneFineRateEntities db = new OneFineRateEntities()) { try { OneFineRate.tblCustomerPointsMap dbCustomerPoint = (OneFineRate.tblCustomerPointsMap)OneFineRateAppUtil.clsUtils.ConvertToObject(customerPointsMap, new OneFineRate.tblCustomerPointsMap()); db.tblCustomerPointsMaps.Add(dbCustomerPoint); return(db.SaveChanges()); } catch (Exception ex) { throw ex; } } }