/// <summary> /// /// </summary> /// <param name="newProfile"></param> /// <returns></returns> public Guid Add(Profile profile) { Proxies.Profile proxy = ProfileToProxy(profile); string guid = _client.AddProfile(proxy); Guid result; if (Guid.TryParse(guid, out result)) { return result; } else { return Guid.Empty; } }
public ActionResult Create(ProfileInputModel model) { try { if (ModelState.IsValid) { Profile newProfile = new Profile() { ID = model.ID, Username = model.Username, Name = model.Name, Surname = model.Surname, Email = model.Email, DateOfBirth = model.DateOfBirth, Address = new Address() { Street = model.Address.Street, City = model.Address.City, PostalCode = model.Address.PostalCode }, Gender = model.Gender, Description = model.Description }; if (model.Photo != null) { int fileLength = model.Photo.ContentLength; byte[] fileData = new byte[fileLength]; System.IO.Stream fileStream = model.Photo.InputStream; fileStream.Read(fileData, 0, fileLength); newProfile.Photo = fileData; newProfile.PhotoMimeType = model.Photo.ContentType; newProfile.PhotoSize = model.Photo.ContentLength; newProfile.PhotoFilename = model.Photo.FileName; newProfile.PhotoUploadedOn = DateTime.Now; } Guid id = _provider.Add(newProfile); return RedirectToAction("Index"); } } catch {} return View(); }
public ProfileInputModel(Profile profile) { ID = profile.ID; Username = profile.Username; Name = profile.Name; Surname = profile.Surname; Email = profile.Email; DateOfBirth = profile.DateOfBirth; Address = new Address() { Street = profile.Address.Street, City = profile.Address.City, PostalCode = profile.Address.PostalCode }; Gender = profile.Gender; Description = profile.Description; }
private Profile ProxyToProfile(Proxies.Profile proxy) { Profile profile = new Profile() { Address = new Address() { Street = proxy.Address.Street, PostalCode = proxy.Address.PostalCode, City = proxy.Address.City }, CreatedOn = proxy.CreatedOn, DateOfBirth = proxy.DateOfBirth, Description = proxy.Description, Email = proxy.Email, Gender = proxy.Gender == Proxies.Gender.Male ? Gender.Male : Gender.Female, ID = Guid.Parse(proxy.ID), Name = proxy.Name, Password = proxy.Password, Photo = proxy.Picture, PhotoUploadedOn = proxy.PictureUploadedOn, Surname = proxy.Surname, UpdatedOn = proxy.UpdatedOn, Username = proxy.Username }; return profile; }
private Proxies.Profile ProfileToProxy(Profile profile) { Proxies.Profile profileProxy = new Proxies.Profile() { Address = new Proxies.Address() { Street = profile.Address.Street, PostalCode = profile.Address.PostalCode, City = profile.Address.City }, CreatedOn = profile.CreatedOn, DateOfBirth = profile.DateOfBirth, Description = profile.Description, Email = profile.Email, Gender = profile.Gender == Gender.Male ? Proxies.Gender.Male : Proxies.Gender.Female, ID = profile.ID.ToString(), Name = profile.Name, Password = profile.Password, Picture = profile.Photo, PictureUploadedOn = profile.PhotoUploadedOn, Surname = profile.Surname, UpdatedOn = profile.UpdatedOn, Username = profile.Username }; return profileProxy; }
/// <summary> /// /// </summary> /// <param name="profileModel"></param> public void Update(Profile profile) { Proxies.Profile proxy = ProfileToProxy(profile); _client.ModifyProfile(proxy); }