public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassLessonModel>(modelParam.ToString()); if (model == null) { return(null); } var parent = _uow.QuizzClasses.GetById(model.QuizzClassId); QuizzClassLesson entity; model.MapToNew(out entity); entity.QuizzClassLesssonIdx = parent.QuizzClassLessonIdx++; _uow.QuizzClasses.Update(parent); _uow.QuizzClassLessons.Add(entity); _svcContainer.QuizzClassMemberUpdateSvc.AddClassLesson(entity.QuizzClassId, false); _uow.SaveChanges(); entity.Comments = new List <QuizzClassLessonComment>(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
// GET api/<controller> public IHttpActionResult Get() { IEnumerable <ShopDTO> shopDtos = shopService.GetShops(); IEnumerable <Shop> shops = MappingUtil.MapCollection <ShopDTO, Shop>(shopDtos); return(Ok(shops)); }
public static Models.Loan MapFrom(this External.LoanObject loanObject, Models.Loan loan = null) { bool changed = false; var _primaryborrower = PersonExtension.MapFrom(loanObject, FieldList.PrimaryBorrower, loan?.PrimaryBorrower); changed = changed || (_primaryborrower != null); var _w2 = AttachmentExtension.MapFrom(loanObject, FieldList.W2, loan?.W2); changed = changed || (_w2 != null); changed = changed || loanObject.ContainsValues(FieldList.LoanAmount); if (changed) { if (loan == null) { loan = new Loan(); } loan.PrimaryBorrower = _primaryborrower; loan.W2 = _w2; MappingUtil.SetValue(loanObject, FieldList.LoanAmount, (val) => loan.LoanAmount = val, loan.LoanAmount); } return(loan); }
// request quizzling public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <DependentRequestFromUserModel>(modelParam.ToString()); if (model == null) { return(null); } DependentRequestFromUser entity; model.MapToNew(out entity); entity.FromUserId = _currentUser.Id; _uow.DependentRequestsFromUser.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); _svcContainer.RelationshipNotificationSvc.QuizzlingNotificationSvc.AddQuizzlingRequestRNotification(entity, true); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzmateMsgModel>(modelParam.ToString()); if (model == null) { return(null); } QuizzmateMsg1 entity = null; model.MapToNew(out entity); _uow.QuizzmateMsg1s.Add(entity); _uow.SaveChanges(); model = MappingUtil.Map <QuizzmateMsg1, QuizzmateMsgModel>(entity); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <AssignmentModel>(modelParam.ToString()); if (model == null) { return(null); } Assignment entity; model.MapToNew <AssignmentModel, Assignment>(out entity); entity.AssignmentGroup = null; entity.CompletedDate = DateTime.UtcNow;; _uow.Assignments.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassAnnouncementModel>(modelParam.ToString()); if (model == null) { return(null); } QuizzClassAnnouncement entity; model.MapToNew(out entity); entity.PostedDate = DateTime.UtcNow; _uow.QuizzClassAnnouncements.Add(entity); _svcContainer.QuizzClassMemberUpdateSvc.AddAnnouncement(model.QuizzClassId, false); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public bool UpdateQuestion(QAQuestionModel model) { try { var entity = MappingUtil.Map <QAQuestionModel, QandAQuestion>(model); entity.Answers = null; if (entity.AddContentType == AddContentTypeEnum.PictureOnly && model.IsImageChanged) { string tmpString; ImageUtil.SaveImage("Test_" + model.TestId.ToString(), model.NewImageFileName, "", model.ImageContent, out tmpString, true); entity.ImageUrl = tmpString; } _uow.QandAQuestions.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public bool UpdateNotifications(DependentNotificationModel model) { try { var dependentEntity = _uow.Dependents.GetAll() .Where(d => d.ChildId == model.ChildId && d.UserId == _currentUser.Id) .FirstOrDefault(); if (dependentEntity != null) { var entity = MappingUtil.Map <DependentNotificationModel, Dependent>(model); entity.Id = dependentEntity.Id; entity.IsPrimary = dependentEntity.IsPrimary; entity.UserId = dependentEntity.UserId; entity.ChildId = dependentEntity.ChildId; _uow.Dependents.Detach(dependentEntity); _uow.Dependents.Update(entity); _uow.SaveChanges(); } return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
public QuizzModel GetQuizzById(int id) { try { QuizzModel model = null; var entity = _uow.Quizzes.GetAll() .Include(q => q.Tests) .Include(q => q.Reviewers) .Where(q => q.Id == id && q.IsDeleted == false) .FirstOrDefault(); if (entity != null) { model = MappingUtil.Map <Quizz, QuizzModel>(entity); } model.ReviewerId = entity.Reviewers.FirstOrDefault().Id; model.TestId = entity.Reviewers.FirstOrDefault().Id; return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public object Post(object modelParam) { try { var model = JsonConvert.DeserializeObject <FriendRequestModel>(modelParam.ToString()); if (model == null) { return(null); } FriendRequest entity; model.MapToNew <FriendRequestModel, FriendRequest>(out entity); entity.RequestFromId = _currentUser.Id; entity.IsNew = true; entity.IsAccepted = null; entity.PostedDate = DateTime.UtcNow; _uow.FriendRequests.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); _svcContainer.NotificationSvc.DepQuizzmateNotificationSvc.AddDepQuizzmateReceiveRequestNotification(entity, false); _svcContainer.NotificationSvc.DepQuizzmateNotificationSvc.AddDepQuizzmateSendRequestNotification(entity, false); _svcContainer.RelationshipNotificationSvc.QuizzmateNotificationSvc.AddQuizzmateRequestRNotification(entity, true); _svcContainer.EmailSvc.SendQuizzmateRequest(entity); return(model); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(null); } }
public bool CreateComment(QuizzCommentModel model) { try { model.AuthorId = _currentUser.Id; model.PostedDate = DateTime.UtcNow; var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Add(entity); _notificationSvc.QuizzNotificationSvc.AddQuizzCommentNotification(model.QuizzId, false); _uow.SaveChanges(); model.Id = entity.Id; model.AuthorName = _currentUser.UserName; model.PostedDate = entity.PostedDate; _notificationSvc.DepQuizzCommentNotificationSvc.AddDepPostCommentNotification(model.Id, false); _notificationSvc.DepQuizzNotificationSvc.AddDepQuizzReceiveCommentNotification(model.QuizzId, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzCommentCreateActivity(model.QuizzId, model.Id, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzReceiveCommentActivity(model.QuizzId, model.Id, false); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public IEnumerable <ProductDTO> GetShopProducts(int shopId) { IEnumerable <ProductDTO> shopProducts = MappingUtil.MapCollection <Product, ProductDTO>(dataset.Products.GetByShop(shopId)); return(shopProducts); }
// resend request public bool Patch(object modelParam) { try { var model = JsonConvert.DeserializeObject <QuizzClassJoinRequestModel>(modelParam.ToString()); if (model == null) { return(false); } var entity = _uow.QuizzClassJoinRequests.GetAll() .Where(qcj => qcj.QuizzClassId == model.QuizzClassId && qcj.UserId == _currentUser.Id) .FirstOrDefault(); entity.PostedDate = DateTime.UtcNow; entity.IsNew = true; _uow.QuizzClassJoinRequests.Update(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
private bool CreateQuestion(QAQuestionModel model) { try { var entity = MappingUtil.Map <QAQuestionModel, QandAQuestion>(model); entity.AuthorId = _currentUser.Id; entity.Question = ""; if (entity.AddContentType == AddContentTypeEnum.PictureOnly) { string tmpString; ImageUtil.SaveImage("Test_" + model.TestId.ToString(), model.NewImageFileName, "", model.ImageContent, out tmpString); entity.ImageUrl = tmpString; } _uow.QandAQuestions.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); model.Question = model.TextContent; return(true); } catch (Exception ex) { _svcContainer.LoggingSvc.Log(ex); return(false); } }
/// <summary> /// 获取多级钻孔数据, /// </summary> /// <returns></returns> public List <MultilevelZKData> GetAll() { List <MultilevelZKData> lstmultilev = new List <MultilevelZKData>(); Dictionary <string, string> dic = new Dictionary <string, string>(); DataTable dtzk = this.GetAllRecordsToDT(); if (dtzk == null) { return(lstmultilev); } List <GeoZkPointsData> lstzk = new List <GeoZkPointsData>(); lstzk = MappingUtil.GetEntityFromDataTable <GeoZkPointsData>(dtzk); var query = from t in dtzk.AsEnumerable() group t by new { prjno = t.Field <string>(GeoZkPointsData.FIELD_F_PROJECTNO), prjname = t.Field <string>(GeoZkPointsData.FIELD_F_PROJECTNAME) } into m select new { prjno = m.Key.prjno, prjname = m.Key.prjname }; if (query.ToList().Count > 0) { query.ToList().ForEach(q => dic.Add(q.prjno, q.prjname)); } foreach (var item in dic) { IEnumerable <GeoZkPointsData> lst = lstzk.Where((zkpoint) => { return(zkpoint.ProjectNo.Equals(item.Key)); }); lstmultilev.Add(new MultilevelZKData(item.Key, item.Value, lst.ToList())); } return(lstmultilev); }
public void UpdateShop(ShopDTO shopDto) { Shop shop = MappingUtil.MapInstance <ShopDTO, Shop>(shopDto); validator.Validate(shop); dataset.Shops.Update(shop); }
public void UpdateProduct(ProductDTO productDto) { Product product = MappingUtil.MapInstance <ProductDTO, Product>(productDto); validator.Validate(product); dataset.Products.Update(product); }
public StudentsViewModel(IStudentService studentService, IDeleteCommandService deleteParameterService, IStudentRepository studentRepository) { this.studentService = studentService; this.deleteCommandService = deleteParameterService; this.studentRepository = studentRepository; Students = MappingUtil.MapToObservebleCollection <Student, StudentDTO>(studentRepository.GetAll()); }
public List <GeoZkPointsData> GetZKDataTest() { DataTable dtzk = this.GetZKDataTableTest(); List <GeoZkPointsData> lstzk = new List <GeoZkPointsData>(); lstzk = MappingUtil.GetEntityFromDataTable <GeoZkPointsData>(dtzk); return(lstzk); }
public List <GeoZkPointsData> GetAllRecords() { DataTable dtzk = this.GetAllRecordsToDT(); List <GeoZkPointsData> lstzk = new List <GeoZkPointsData>(); lstzk = MappingUtil.GetEntityFromDataTable <GeoZkPointsData>(dtzk); return(lstzk); }
public void HandleMapping <TModel>(TModel model, Item item, IPropertyMeta propertyMeta, ICache cache, IItemMapper itemMapper) { var itemPropertyMappings = MappingUtil.GetItemPropertyMappers(cache); if (itemPropertyMappings.ContainsKey(propertyMeta.PropertyKey)) { itemPropertyMappings[propertyMeta.PropertyKey].SetItemPropertyMapping(model, propertyMeta, item); } }
// Get Not needed: QAQuestion will already get them thru DB Call public bool CreateAnswer(QAAnswerModel model) { var entity = MappingUtil.Map <QAAnswerModel, QandAAnswer>(model); _uow.QandAAnswers.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public bool CreateTestSetting(TestSettingModel model) { var entity = MappingUtil.Map <TestSettingModel, TestSetting>(model); _uow.TestSettings.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public TextFlashCardModel GetTextFlashCardById(int id) { TextFlashCardModel model = null; var entity = _uow.TextFlashCards.GetById(id); if (entity != null) { model = MappingUtil.Map <TextFlashCard, TextFlashCardModel>(entity); } return(model); }
public bool CreateChoice(MultiChoiceSameChoiceModel model) { var entity = MappingUtil.Map <MultiChoiceSameChoiceModel, MultiChoiceSameChoice>(model); _uow.MultiChoiceSameChoices.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public MultiChoiceSameQuestionModel GetQuestionById(int id) { var entity = _uow.MultiChoiceSameQuestions.GetAll() .Include(q => q.ChoiceGroup.Choices) .Where(q => q.Id == id) .FirstOrDefault(); var model = MappingUtil.Map <MultiChoiceSameQuestion, MultiChoiceSameQuestionModel>(entity); return(model); }
public TestSettingModel GetTestSetting(int id) { TestSettingModel model = null; var entity = _uow.TestSettings.GetById(id); if (entity != null) { model = MappingUtil.Map <TestSetting, TestSettingModel>(entity); } return(model); }
public QuickNoteModel GetQuickNoteById(int id) { QuickNoteModel model = null; var entity = _uow.QuickNotes.GetById(id); if (entity != null) { model = MappingUtil.Map <QuickNote, QuickNoteModel>(entity); } return(model); }
// PUT api/<controller>/5 public IHttpActionResult Put(int id, [FromBody] Product product) { ProductDTO productDto = MappingUtil.MapInstance <Product, ProductDTO>(product); try { productService.UpdateProduct(productDto); } catch (EntityValidationExeption ex) { return(BadRequest(ex.Message)); } return(Ok()); }