public static PersonSelectRequest GetPersonSelectRequest(string uid) { var request = new PersonSelectRequest(); request.UId = uid; return(request); }
internal static PersonUpdateRequest GetPersonUpdateRequest(PersonSelectRequest selectRequest, PersonInsertRequest insertRequest) { var request = new PersonUpdateRequest(); request.UId = selectRequest.UId; request.FirstName = insertRequest.FirstName; request.LastName = insertRequest.LastName; request.Phone = insertRequest.Phone; return(request); }
public ActionResult Detail(string uid) { var request = new PersonSelectRequest(uid); if (request.IsNotValid()) { return(RedirectToNotFound()); } var response = _personService.Select(request); if (response.Status) { var model = PersonMapper.MapViewModelFromModel(response.Model); return(View(model)); } return(RedirectToNotFound()); }
public PersonSelectResponse Select(PersonSelectRequest request) { var response = new PersonSelectResponse(); if (request.IsNotValid()) { response.Message = ConstHelper.REQUEST_NOT_VALID; return(response); } try { var cacheKey = "Person-" + request.UId; var cachedItem = CacheManager.GetItem(cacheKey); if (cachedItem == null) { var entity = _personRepository.SelectOne(request.UId); var model = PersonMapper.MapModelFromEntity(entity); response.Model = model; CacheManager.AddOrUpdateItem(cacheKey, model); } else { response.Model = (PersonModel)cachedItem; } } catch (Exception ex) { response.Message = string.Format("Selecting failed while getting from database!{0}{1}", Environment.NewLine, ex.Message); return(response); } response.Status = true; response.Message = "Person selected."; return(response); }