public bool AddToIos(PromotionLog data, out string errormsg, int id = 1) { errormsg = string.Empty; try { PromotionLog promotionLog = new PromotionLog { UserID = id, EventID = WhereIsPoliceID, Platform = "Ios", Datetime = DateTime.Now, FingerPrint = data.FingerPrint }; DbEntity.PromotionLog.Add(promotionLog); DbEntity.SaveChanges(); var user_eventByID = DbEntity.User_MarketingEvent.First(user_event => user_event.UserID == id); user_eventByID.UserIosCount = ++user_eventByID.UserIosCount; DbEntity.SaveChanges(); } catch (Exception ex) { errormsg = ex.InnerException?.Message ?? ex.Message; } return(errormsg.Length == 0); }
public ActionResult AddToIos(PromotionLog data, int id = 1) { id = int.Parse(Request.Cookies["UserID"].Value); if (ModelState.IsValid) { try { fingerPrintService.AddToIos(data, out errorMsg, id); } catch { errorMsg = "Json格式錯誤"; } } else { errorMsg = ModelState.Values.FirstOrDefault(p => p.Errors.Count > 0)?.Errors.FirstOrDefault()?.ErrorMessage; } return(new EmptyResult()); }