public HttpResponseMessage Get() { string userId = string.Empty; // Try to get userid from header var header = Request.Headers.Where(h => string.Compare(h.Key, "UserId", true) == 0).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(header.Key)) { userId = header.Value.FirstOrDefault(); } if (!string.IsNullOrWhiteSpace(userId)) { using (var context = ContextManager.CreateContext()) { var user = context.Users.Where(row => string.Compare(row.UserId, userId, true) == 0).FirstOrDefault(); if (user != null) { user = new LoyaltyModel { UserId = userId, LoyaltyNumber = user.LoyaltyNumber }; return(Request.CreateResponse(HttpStatusCode.OK, user)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public LoyaltyViewModel() { var comp = Convert.ToInt32(App.Current.Properties["Company_Id"].ToString()); if (App.Current.Properties["Action"].ToString() == "Edit") { CreatVisible = "Collapsed"; UpdVisible = "Visible"; selectedLoyalty = App.Current.Properties["LoyaltyEdit"] as LoyaltyModel; App.Current.Properties["Action"] = ""; } else if (App.Current.Properties["Action"].ToString() == "View") { selectedLoyalty = App.Current.Properties["LoyaltyView"] as LoyaltyModel; App.Current.Properties["Action"] = ""; } else { UpdVisible = "Collapsed"; CreatVisible = "Visible"; selectedLoyalty = new LoyaltyModel(); selectedLoyalty.FROMDATE = System.DateTime.Now; selectedLoyalty.TODATE = System.DateTime.Now; GetLoyalty(comp); } }
public async Task <ActionResult> Update(LoyaltyModel model) { if (!ModelState.IsValid) { return(View("Index", model)); } var obj = db.LoyaltyPreferences.Find(model.Id); obj.MonthsToExpiry = model.MonthsToExpiry; obj.Subject = model.Subject; obj.Body = model.Body; obj.CouponCode = model.CouponCode; obj.CouponDiscountRate = model.CouponDiscountRate; obj.PointsLimit = model.PointsLimit; db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.Notifications.PushNotificaiton(string.Format("You updated loyalty preferences")); await db.SaveChangesAsync(); return(View("Index", model)); }
public HttpResponseMessage Post([FromBody] JObject jsonUserId) { // Get userid if (jsonUserId != null) { string userId = jsonUserId["userid"].ToString(); using (var context = ContextManager.CreateContext()) { string loyalty = this.LoyaltyNumber(userId); var user = context.Users.Where(row => string.Compare(row.UserId, userId, true) == 0).FirstOrDefault(); if (user != null) { user.LoyaltyNumber = loyalty; } else { user = new LoyaltyModel { UserId = userId, LoyaltyNumber = loyalty }; context.Users.Add(user); } context.SaveChangesAsync(); return(Request.CreateResponse(HttpStatusCode.OK, user)); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public HttpResponseMessage LoyaltyAdd(LoyaltyModel _LoyaltyModel) { try { bool conn = false; conn = db.Database.Exists(); if (!conn) { ConnectionTools.changeToLocalDB(db); conn = db.Database.Exists(); } if (conn) { if (_LoyaltyModel.LOYALTI_ID == null || _LoyaltyModel.LOYALTI_ID == 0) { TBL_LOYALTY gd = new TBL_LOYALTY(); gd.COLLECTION = _LoyaltyModel.COLLECTION; gd.COMPANY_ID = _LoyaltyModel.COMPANY_ID; gd.CUSTOMERGROUP = _LoyaltyModel.CUSTOMERGROUP; gd.FROMDATE = DateTime.Now; gd.IS_DELETE = false; gd.ISACTIVE = _LoyaltyModel.ISACTIVE; gd.ISDEFAULT = _LoyaltyModel.ISDEFAULT; gd.SETTINGSNAME = _LoyaltyModel.SETTINGSNAME; gd.TODATE = DateTime.Now; gd.WEIGHTAGE = _LoyaltyModel.WEIGHTAGE; db.TBL_LOYALTY.Add(gd); db.SaveChanges(); if (_LoyaltyModel.ListGrid1.Count > 0) { foreach (var item in _LoyaltyModel.ListGrid1) { TBL_LOYALTY_Exceedings tbLexceed = new TBL_LOYALTY_Exceedings(); tbLexceed.Company_ID = _LoyaltyModel.COMPANY_ID; tbLexceed.Flatpoints = item.FlatPoints; tbLexceed.InvoiveExceeding = item.InvoiceExceeding; tbLexceed.LOYALTY_ID = item.LOYALTI_ID; db.TBL_LOYALTY_Exceedings.Add(tbLexceed); db.SaveChanges(); } } } return(Request.CreateResponse(HttpStatusCode.OK, "ok")); } else { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } } catch (Exception ex) { throw; } finally { ConnectionTools.ChangeToRemoteDB(db); } }
public ActionResult DeleteConfirmed(int id) { LoyaltyModel loyaltyModel = db.Users.Find(id); db.Users.Remove(loyaltyModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,UserId,LoyaltyNumber")] LoyaltyModel loyaltyModel) { if (ModelState.IsValid) { db.Entry(loyaltyModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loyaltyModel)); }
public ActionResult Create([Bind(Include = "Id,UserId,LoyaltyNumber")] LoyaltyModel loyaltyModel) { if (ModelState.IsValid) { db.Users.Add(loyaltyModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loyaltyModel)); }
public async Task <IActionResult> LoyaltyOverview(int loyaltyNumber) { ViewBag.Title = "Your Account"; var customer = await _customerRepository.GetCustomerByLoyaltyNumber(loyaltyNumber); var pointsNeeded = int.Parse(_configuration["CustomerPortalSettings:PointsNeeded"]); var loyaltyModel = LoyaltyModel.FromCustomer(customer, pointsNeeded); return(View(loyaltyModel)); }
// GET: LoyaltyModels/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LoyaltyModel loyaltyModel = db.Users.Find(id); if (loyaltyModel == null) { return(HttpNotFound()); } return(View(loyaltyModel)); }
//private EventHandler Timer_Tick; public LoyaltyViewModel() { loyaltymodel = new LoyaltyModel(); loyaltymodel.Codeproduit = string.Empty; loyaltymodel.Codebarre = string.Empty; //List<Produit> produits = new List<Produit>(); loyaltymodel.Produits = new ObservableCollection <Produit>(); //DispatcherTimer timer = new DispatcherTimer(); //timer.Interval = TimeSpan.FromSeconds(1); //timer.Tick += Timer_Tick; //timer.Start(); loyaltymodel.VisibiliteInformations = Visibility.Hidden; loyaltymodel.VisibiliteErreur = Visibility.Hidden; }
public ActionResult Index() { var prefs = db.LoyaltyPreferences.FirstOrDefault(); var model = new LoyaltyModel { CouponCode = prefs.CouponCode, CouponDiscountRate = prefs.CouponDiscountRate, MonthsToExpiry = prefs.MonthsToExpiry, Subject = prefs.Subject, Body = prefs.Body, Id = prefs.Id, PointsLimit = prefs.PointsLimit }; return(View("Index", model)); }
public HttpResponseMessage LoyaltyUpdate(LoyaltyModel _LoyaltyModel) { try { bool conn = false; conn = db.Database.Exists(); if (!conn) { ConnectionTools.changeToLocalDB(db); conn = db.Database.Exists(); } if (conn) { if (_LoyaltyModel.LOYALTI_ID != null || _LoyaltyModel.LOYALTI_ID != 0) { var gd = (from a in db.TBL_LOYALTY where a.LOYALTY_ID == _LoyaltyModel.LOYALTI_ID select a).FirstOrDefault(); gd.COLLECTION = _LoyaltyModel.COLLECTION; gd.COMPANY_ID = _LoyaltyModel.COMPANY_ID; gd.CUSTOMERGROUP = _LoyaltyModel.CUSTOMERGROUP; gd.FROMDATE = DateTime.Now; gd.IS_DELETE = false; gd.ISACTIVE = _LoyaltyModel.ISACTIVE; gd.ISDEFAULT = _LoyaltyModel.ISDEFAULT; gd.SETTINGSNAME = _LoyaltyModel.SETTINGSNAME; gd.TODATE = DateTime.Now; gd.WEIGHTAGE = _LoyaltyModel.WEIGHTAGE; db.SaveChanges(); } return(Request.CreateResponse(HttpStatusCode.OK, "ok")); } else { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } } catch (Exception ex) { throw; } finally { ConnectionTools.ChangeToRemoteDB(db); } }
public async Task <IActionResult> LoyaltyOverview(int loyaltyNumber) { ViewBag.Title = "Your points"; var userLoyaltyNumber = int.Parse(User.Claims.FirstOrDefault(a => a.Type == "loyalty")?.Value ?? "0"); if (userLoyaltyNumber != loyaltyNumber) { SecurityLog.Warning("Unauthorized access attempted on {LoyaltyNum}", loyaltyNumber); //Log.Warning("Unauthorized access attempted on {LoyaltyNum}", loyaltyNumber); throw new Exception($"Unauthorized to see loyalty number {loyaltyNumber}!!"); } var customer = await repo.GetCustomerByLoyaltyNumber(loyaltyNumber); var pointsNeeded = int.Parse(config["CustomerPortalSettings:PointsNeeded"]); var loyaltyModel = LoyaltyModel.FromCustomer(customer, pointsNeeded); return(View(loyaltyModel)); }
private void AddBehaviours(CampaignGameStarter gameInitializer) { _modOptions = new ModOptions(); _revolutionBehaviour = new Revolution(); _mobChecker = new MobChecker(); _debugBehaviour = new DebugCampaignBehaviour(); _common = new Common(); gameInitializer.AddBehavior(_revolutionBehaviour); gameInitializer.AddBehavior(_modOptions); gameInitializer.AddBehavior(_mobChecker); gameInitializer.AddBehavior(_debugBehaviour); _loyaltyModel = new LoyaltyModel(); _loyaltyModel.RevolutionBehaviour = _revolutionBehaviour; gameInitializer.AddModel(_loyaltyModel); gameInitializer.LoadGameTexts($"{BasePath.Name}Modules/Revolutions/ModuleData/global_strings.xml"); }
public async Task <ActionResult> LoyaltyOverview(int loyaltyNumber) { ViewBag.Title = "Your points"; var cookieName = "LoyaltyInfo"; if (Request.Cookies[cookieName] != null) { var loyaltyInfo = JsonConvert.DeserializeObject <LoyaltyModel>(Request.Cookies[cookieName].Value); return(View(loyaltyInfo)); } var customer = await repo.GetCustomerByLoyaltyNumber(loyaltyNumber); var pointsNeeded = int.Parse(ConfigurationManager.AppSettings["CustomerPortalSettings:PointsNeeded"]); var loyaltyModel = LoyaltyModel.FromCustomer(customer, pointsNeeded); Response.Cookies.Add(new System.Web.HttpCookie("LoyaltyInfo", JsonConvert.SerializeObject(loyaltyModel)) { Expires = DateTime.Now.AddHours(2) }); return(View(loyaltyModel)); }
//private LoyaltyModel loyaltymodel; public void LoyaltyViewModel() { loyaltymodel = new LoyaltyModel(); loyaltymodel.Codeproduit = string.Empty; loyaltymodel.Codebarre = string.Empty; }