public IActionResult Post([FromBody] ProfileBO p) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.ProfileService.Create(p))); }
public ProfileBO Create(ProfileBO profile) { using (var uow = facade.UnitOfWork) { var newProfile = uow.ProfileRepo.Create(conv.Convert(profile)); uow.Complete(); return(conv.Convert(newProfile)); } }
public void TestListProfile() { ApplicationSeeder.Seed(); var bo = new ProfileBO(); var resList = bo.List(); Assert.IsTrue(resList.Success && resList.Result.Count > 0); }
public void ConvertBOToEntId() { var profile = new ProfileBO() { Id = 1 }; Profile bo = converter.Convert(profile); Assert.AreEqual(bo.Id, 1); }
public void TestCreateAndListProfile() { ApplicationSeeder.Seed(); var bo = new ProfileBO(); var profile = new Profile("John Doe", "Portugal", DateTime.Now); var resCreate = bo.Create(profile); var resGet = bo.Read(profile.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public ProfileBO Create(ProfileBO profile) { if (profile == null) { return(null); } using (var unitOfWork = _facade.UnitOfWork) { var createdProfile = unitOfWork.ProfileRepository.Create(_converter.Convert(profile)); unitOfWork.Complete(); return(_converter.Convert(createdProfile)); } }
public void TestCreateAndListClientAsync() { ApplicationSeeder.Seed(); var bo = new ClientBO(); var foreignBO = new ProfileBO(); var client = new Client(foreignBO.ListUndeleted().Result.First().Id); var resCreate = bo.CreateAsync(client).Result; var resGet = bo.ReadAsync(client.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestDeleteProfile() { ApplicationSeeder.Seed(); var bo = new ProfileBO(); var resList = bo.List(); var total = resList.Result.Count; var resDelete = bo.Delete(resList.Result.First().Id); var list = bo.ListUndeleted(); Assert.IsTrue(resDelete.Success && resList.Success && list.Result.Count == (total - 1)); }
internal Profile Convert(ProfileBO profile) { if (profile == null) { return(null); } return(new Profile() { Id = profile.Id, FirstName = profile.FirstName, LastName = profile.LastName, Address = profile.Address }); }
public IActionResult Put(int id, [FromBody] ProfileBO profile) { if (id != profile.Id) { return(StatusCode(404, "Id does not match profile Id!")); } try { return(Ok(_facade.ProfileService.Update(profile))); } catch (Exception) { return(BadRequest($"Couldn't update the profile!")); } }
public IActionResult Put(int id, [FromBody] ProfileBO p) { if (id != p.Id) { return(BadRequest("Path ID does not match object ID in json object")); } try { return(Ok(facade.ProfileService.Update(p))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public ProfileBO DisplayUser(int iUserId) { DataSet objDataSet = null; ProfileBO objProfileBO = null; List <ProcParameterBO> ObjProcParameterBOList = new List <ProcParameterBO>(); try { ProcParameterBO objDbParameter = new ProcParameterBO(); objDbParameter.Direction = ParameterDirection.Input; objDbParameter.ParameterName = "@iUserId"; objDbParameter.dbType = DbType.Int32; objDbParameter.ParameterValue = iUserId; ObjProcParameterBOList.Add(objDbParameter); objDataSet = objDBAccess.execuitDataSet(ProcViewUser, ref ObjProcParameterBOList); if (objDataSet != null && objDataSet.Tables[0].Rows.Count > 0) { objProfileBO = new ProfileBO(); objProfileBO.UserId = Convert.ToInt32(objDataSet.Tables[0].Rows[0][0].ToString()); objProfileBO.FirstName = objDataSet.Tables[0].Rows[0][1].ToString(); objProfileBO.MiddleName = objDataSet.Tables[0].Rows[0][2].ToString(); objProfileBO.LastName = objDataSet.Tables[0].Rows[0][3].ToString(); objProfileBO.Gender = objDataSet.Tables[0].Rows[0][4].ToString(); objProfileBO.MobileNumber = objDataSet.Tables[0].Rows[0][5].ToString(); objProfileBO.AlternateMobileNumber = objDataSet.Tables[0].Rows[0][6].ToString(); objProfileBO.EmailAddress = objDataSet.Tables[0].Rows[0][7].ToString(); objProfileBO.Language = objDataSet.Tables[0].Rows[0][8].ToString(); objProfileBO.Qualification = objDataSet.Tables[0].Rows[0][9].ToString(); objProfileBO.Country = objDataSet.Tables[0].Rows[0][10].ToString(); objProfileBO.City = objDataSet.Tables[0].Rows[0][11].ToString(); objProfileBO.RoleName = objDataSet.Tables[0].Rows[0][12].ToString(); objProfileBO.Department = objDataSet.Tables[0].Rows[0][13].ToString(); objProfileBO.Address = objDataSet.Tables[0].Rows[0][14].ToString(); objProfileBO.Photo = objDataSet.Tables[0].Rows[0][15].ToString(); objProfileBO.ActualFileName = objDataSet.Tables[0].Rows[0][16].ToString(); } } catch (Exception ex) { ExceptionError.Error_Log(ex, "DisplayUser"); throw ex; } return(objProfileBO); }
public void TestUpdateProfile() { ApplicationSeeder.Seed(); var bo = new ProfileBO(); var resList = bo.List(); var item = resList.Result.FirstOrDefault(); item.Country = "Spain"; var resUpdate = bo.Update(item); var list = bo.ListUndeleted(); Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().Country == "Spain"); }
public ProfileBO Update(ProfileBO entityToUpdate) { using (var unitOfWork = _facade.UnitOfWork) { var profileFromDB = unitOfWork.ProfileRepository.GetById(entityToUpdate.Id); if (profileFromDB == null) { return(null); } profileFromDB.FirstName = entityToUpdate.FirstName; profileFromDB.LastName = entityToUpdate.LastName; profileFromDB.Address = entityToUpdate.Address; unitOfWork.ProfileRepository.Update(profileFromDB); unitOfWork.Complete(); return(_converter.Convert(profileFromDB)); } }
public void TestUpdateClientAsync() { ApplicationSeeder.Seed(); var bo = new ClientBO(); var foreignBO = new ProfileBO(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.ProfileId = foreignBO.ListUndeleted().Result.Last().Id; var resUpdate = bo.UpdateAsync(item).Result; var list = bo.ListUndeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && list.Result.First().ProfileId == foreignBO.ListUndeleted().Result.Last().Id); }
public ActionResult Index() { ViewBag.Title = "Profile"; ViewBag.MainTitle = "User Profile"; ViewBag.Icon = "fa fa-user"; ProfileBAL objProfileBAL = new ProfileBAL(); ProfileBO objProfileBO = objProfileBAL.DisplayUser(Convert.ToInt32(ViewData["LoginUserId"])); // @ViewBag.ImagePath = Url.Content("../assets/images/user-1.png"); if (objProfileBO.ActualFileName == "" || objProfileBO.ActualFileName == null) { ViewBag.ImagePath = Url.Content("../assets/images/user-1.png"); } else { ViewBag.ImagePath = Url.Content(strViewUploadPhotoPath + objProfileBO.ActualFileName); } return(View(objProfileBO)); }
public ProfileBO Update(ProfileBO profile) { using (var uow = facade.UnitOfWork) { var newProfile = uow.ProfileRepo.Get(profile.Id); if (newProfile == null) { throw new InvalidOperationException("Profile not found"); } newProfile.Address = profile.Address; newProfile.Email = profile.Email; newProfile.Id = profile.Id; newProfile.FirstName = profile.FirstName; newProfile.LastName = profile.LastName; newProfile.PhoneNumber = profile.PhoneNumber; uow.Complete(); return(conv.Convert(newProfile)); } }
/// <summary> /// Hide or show the banner depending on user preference. /// </summary> private void ShowBanner() { if (Request.IsAuthenticated == true) { ProcessFlow.AccountController accountController = new ProcessFlow.AccountController(); // Retrieve the account information from the account controller AccountInfo myAccount = accountController.GetAccountInfo(false); if (myAccount != null) { areaBanner.Visible = myAccount.IsShowBanners; string categoryKey = myAccount.Category; string bannerKey = "Banner" + categoryKey; string bannerPath = ""; if (Cache[bannerKey] != null) { // If the data is already cached, then used the cached copy bannerPath = ((string)Cache[bannerKey]); } else { // If the data is not cached, then create a new profile object object and request the data ProfileBO profile = new ProfileBO(); bannerPath = profile.GetBannerPath(categoryKey); // Store the results of the call in the Cache and set the time out to 6 hours Cache.Add(bannerKey, bannerPath, null, DateTime.Now.AddHours(6), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } areaImage.InnerHtml = bannerPath; } } }
public IActionResult Post([FromBody] ProfileBO profile) { return(StatusCode(403, "Can't create a profile without a user. Create a new user to create a new profile.")); }