public async Task<ActionResult> CompleteAsync() { if (Request.QueryString["serviceInterval"] != null) { ServiceInterval = Convert.ToInt32(Request.QueryString["serviceInterval"]); } var auth = new MvcAuthorizer { CredentialStore = new SessionStateCredentialStore { ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"].ToString(), ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"].ToString() } }; await auth.CompleteAuthorizeAsync(Request.Url); // Profile model = new Data.Models.Profile(); var credentials = auth.CredentialStore; model.AccessToken = credentials.OAuthToken; model.TokenSecret = credentials.OAuthTokenSecret; model.Username = credentials.ScreenName; model.UserId = credentials.UserID.ToString(); model.ProfileTypeID = 3; model.Interval = ServiceInterval; SaveTwitterInfo(model); return RedirectToAction("Index", "Profile"); }
public ServiceResponse <Data.Models.Profile> CreateProfile(Data.Models.Profile profile) { try { _db.Profiles.Add(profile); _db.SaveChanges(); return(new ServiceResponse <Data.Models.Profile> { IsSuccess = true, Message = "New profile added", Time = DateTime.UtcNow, Data = profile }); } catch (Exception e) { return(new ServiceResponse <Data.Models.Profile> { IsSuccess = false, Message = e.StackTrace, Time = DateTime.UtcNow, Data = profile }); } }
private async void OnTakeImageAsync(object obj) { await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { StaticFunctions.DisplayAlert_ProvideInformationAsync("Camera", "This device havent camera."); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Profilepic", Name = "Profile.jpg" }); if (file == null) { return; } profile = new Data.Models.Profile() { ImagePath = file.AlbumPath, Name = profile.Name }; }
private decimal CalculatePrice(Tour tour, Data.Models.Profile profile) { if (tour == null) { throw new ValidationException("There is no tour with such id.", "TourId"); } if (profile == null) { throw new ValidationException("User does not exist.", "UserId"); } var lastBusinessValues = _uow.BusinessValues .Get() .OrderByDescending(o => o.TimeSet) .FirstOrDefault(); if (lastBusinessValues == null) { throw new ValidationException("No business values set"); } decimal price = tour.Price; if (profile.Orders != null && profile.Orders.Count(o => o.Status == Enums.OrderStatus.Payed) > 0) { int nextDiscount = profile.Orders.Count(o => o.Status == Enums.OrderStatus.Payed) * lastBusinessValues.DiscountPercentIncrement; if (nextDiscount > lastBusinessValues.DiscountPercentCap) { nextDiscount = lastBusinessValues.DiscountPercentCap; } price -= price * ((decimal)nextDiscount / 100); } return(price); }
public void Save() { try { string userInfo = getUserDetail(); JavaScriptSerializer jss = new JavaScriptSerializer(); var obj = (IDictionary<string, object>)jss.DeserializeObject(userInfo); Profile model = new Data.Models.Profile(); model.AccessToken = AccessToken; model.UserId = obj["id"].ToString(); model.Username = obj["name"].ToString(); model.ProfileTypeID = ProfileTypeId; model.PageId = PageId;// "738024112987033"; model.Interval = ServiceInterval; ServiceStack.Data.IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["db"].ConnectionString, MySqlDialect.Provider); using (IDbConnection db = dbFactory.Open()) { //Check user Exits var alreadyExist = db.Select<Profile>().Where(u => u.UserId == model.UserId).FirstOrDefault(); if (alreadyExist != null) { Response.Redirect("index"); } db.Insert<Profile>(model); } Response.Redirect("index"); } catch (Exception ex) { JavaScriptSerializer jss = new JavaScriptSerializer(); Response.Redirect("index"); // throw ex; } }
public ServiceResponse <Data.Models.Profile> UpdateProfile(Data.Models.Profile profile) { throw new NotImplementedException(); }
public ProfileviewModel() { TakeImageCommand = new Command(OnTakeImageAsync); NextCommand = new Command(OnNextAsync); profile = new Data.Models.Profile(); }