public static void Register() { // Use this class to set configuration options for your mobile service var options = new ConfigOptions(); options.LoginProviders.Remove(typeof(AzureActiveDirectoryLoginProvider)); options.LoginProviders.Add(typeof(AzureActiveDirectoryExtendedLoginProvider)); options.LoginProviders.Add(typeof(FBLoginProvider)); options.LoginProviders.Add(typeof(VKLoginProvider)); // Use this class to set WebAPI configuration options var config = ServiceConfig.Initialize(new ConfigBuilder(options)); // To display errors in the browser during development, uncomment the following // line. Comment it out again when you deploy your service for production use. config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Include; config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Include; config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Objects; config.MessageHandlers.Add(new ThrottlingHandler { Policy = new ThrottlePolicy(5) { IpThrottling = true }, Repository = new CacheRepository() }); Mapper.Initialize(cfg => { DTOMapper.CreateMapping(cfg); }); //var migrator = new DbMigrator(new Configuration()); // migrator.Update(); // Database.SetInitializer(new appartmenthostInitializer()); }
public async Task <IActionResult> Post([FromBody] RolesDTO model) { AddRolesModel role = new DTOMapper <RolesDTO, AddRolesModel>().Serialize(model); var roleid = await _rolesService.AddRoles(role); return(Ok(roleid)); }
public async Task <IActionResult> Put([FromBody] CustomerUpdateStatusDTO customerUpdateStatusDTO) { CustomerUpdateStatusModel CustomerUpdateStatus = new DTOMapper <CustomerUpdateStatusDTO, CustomerUpdateStatusModel>().Serialize(customerUpdateStatusDTO); int CustomerUpdateStatusId = await _iCustomerService.CustomersUpdateStatus(CustomerUpdateStatus); return(Ok(CustomerUpdateStatusId)); }
public Order FindOrder(int id) { Order order = null; if (id > 0) { using (var db = eCommerce.Accessors.EntityFramework.eCommerceDbContext.Create()) { EntityFramework.Order model = db.Orders.Find(id); if (model != null) { order = DTOMapper.MapOrder(model); var orderItemModels = from ol in db.OrderLines where ol.OrderId == id select ol; var orderLines = new List <OrderLine>(); foreach (var cim in orderItemModels) { var orderLine = DTOMapper.Map <OrderLine>(cim); orderLines.Add(orderLine); } order.OrderLines = orderLines.ToArray(); } } } return(order); }
public async Task <IActionResult> Post(CustomerDTO model) { CustomerModel CustomerScreen = new DTOMapper <CustomerDTO, CustomerModel>().Serialize(model); var Response = await _iCustomerService.AddCustomers(CustomerScreen); return(Ok(Response)); }
public async Task <IActionResult> Put([FromBody] CustomerUpdateDTO customerUpdateDTO) { CustomerUpdateModel StaffUpdate = new DTOMapper <CustomerUpdateDTO, CustomerUpdateModel>().Serialize(customerUpdateDTO); int UpdateId = await _iCustomerService.UpdateCustomers(StaffUpdate); return(Ok(UpdateId)); }
public ScheduleSessionsDTO GetSessionsFromSchedule(long scheduleId) { var mapper = new DTOMapper(DbContext); // get schedule entity var schedule = DbContext.Set <ScheduleEntity>().Find(scheduleId); if (schedule == null) { return(new ScheduleSessionsDTO() { ScheduleId = scheduleId }); } // get sessions data var sessions = schedule.Sessions.Select(x => GetSession(x.SessionId, includeScheduleData: false)).ToArray(); // construct DTO var scheduleSessions = new ScheduleSessionsDTO() { ScheduleId = schedule.ScheduleId, ScheduleName = schedule.Name, Sessions = sessions, SessionsCount = sessions.Count(), SessionsFinished = sessions.Count(x => x.SessionResultId != null), RacesCount = sessions.Count(x => x.SessionType == iRLeagueManager.Enums.SessionType.Race), RacesFinished = sessions.Count(x => x.SessionType == iRLeagueManager.Enums.SessionType.Race && x.SessionResultId != null) }; return(scheduleSessions); }
public void DTOMapper_CartMap_1() { var input = new Accessors.EntityFramework.Cart { BillingCity = "Bill City", BillingPostal = "Bill Postal", BillingAddr1 = "Bill Addr1", BillingAddr2 = "Bill Addr2", ShippingCity = "Shipping City", ShippingPostal = "Shipping Postal", ShippingAddr1 = "Shipping Addr1", ShippingAddr2 = "Shipping Addr2", }; var result = DTOMapper.Map <Cart>(input); Assert.AreEqual(input.BillingCity, result.BillingAddress.City); Assert.AreEqual(input.BillingPostal, result.BillingAddress.Postal); Assert.AreEqual(input.BillingAddr1, result.BillingAddress.Addr1); Assert.AreEqual(input.BillingAddr2, result.BillingAddress.Addr2); Assert.AreEqual(input.BillingState, result.BillingAddress.State); Assert.AreEqual(input.ShippingCity, result.ShippingAddress.City); Assert.AreEqual(input.ShippingPostal, result.ShippingAddress.Postal); Assert.AreEqual(input.ShippingAddr1, result.ShippingAddress.Addr1); Assert.AreEqual(input.ShippingAddr2, result.ShippingAddress.Addr2); Assert.AreEqual(input.ShippingState, result.ShippingAddress.State); }
public async Task <IActionResult> Post([FromBody] TagDTO model) { TagModel tag = new DTOMapper <TagDTO, TagModel>().Serialize(model); var response = await _tagService.AddTags(tag); return(Ok(response)); }
public async Task <IActionResult> UpdateTags([FromBody] TagUpdateDTO model) { TagUpdateModel Updatetag = new DTOMapper <TagUpdateDTO, TagUpdateModel>().Serialize(model); var response = await _tagService.UpdateTags(Updatetag); return(Ok(response)); }
internal List <Subscriptions> GetAllSubscription() { List <List <Dictionary <string, string> > > persistentCarrier = new List <List <Dictionary <string, string> > >(); string query = "Select * from mlo.subscriptions;"; Subscriptions subs = null; List <Subscriptions> subsList = new List <Subscriptions>(); try { persistentCarrier = DBUtility.ExecuteQuery(query); SBMapper map = new SBMapper(PropertyMapper.MapSubscriptions()); foreach (Dictionary <string, string> eachCarrier in persistentCarrier[0]) { subs = new Subscriptions(); string json = new DTOMapper().Mapper(eachCarrier, subs, map); subs = JsonConvert.DeserializeObject <Subscriptions>(json); subsList.Add(subs); } } catch (Exception ex) { throw ex; } return(subsList); }
internal List <Location> GetAllLocation() { List <Location> locations = new List <Location>(); List <List <Dictionary <String, string> > > persistentCarrier = new List <List <Dictionary <String, string> > >(); try { String query = "SELECT * FROM `mlo`.`location`;"; persistentCarrier = DBUtility.ExecuteQuery(query); SBMapper map = new SBMapper(); map.MapperCollection = PropertyMapper.MapLocation(); Location loc = null; foreach (Dictionary <string, string> eachCarrier in persistentCarrier[0]) { loc = new Location(); string json = DTOMapper.Mapper(eachCarrier, loc, map); Console.WriteLine("Destination = " + (json)); loc = JsonConvert.DeserializeObject <Location>(json); locations.Add(loc); } } catch (Exception ex) { throw ex; //Logger.Log(Level.Error, "Error in SignIn :: " + ex.Message + "\n Caused By :- " + ex.StackTrace); //throw new WebFaultException<CustomFault>(new CustomFault("Error in SignIn ", skyboInternalSvrErr, ex.Message), internalSvrErr); } return(locations); }
public IEnumerable <SimpleNews> SearchByField(string searchQuery, string fieldName, int page) { fieldName = fieldName.ToLower(); if (fieldName.Equals("content")) { fieldName = "text"; } if (fieldName.Equals("all")) { return(_newsRepository.SimpleSearch(searchQuery, page).Select(n => DTOMapper.GetSimpleNews(n)).ToList()); } else if (fieldName.Equals("tag")) { var fieldsName = new List <string>() { "thread.site", "entities.persons.name", "entities.locations.name", "entities.organizations.name" }; return(_newsRepository.SearchByFields(searchQuery, fieldsName, page).Select(n => DTOMapper.GetSimpleNews(n)).ToList()); } else { return(_newsRepository.SearchByField(searchQuery, fieldName, page).Select(n => DTOMapper.GetSimpleNews(n)).ToList()); } }
// -------------------------------------------------------------------------------------------------------------------------- public NewWineEntry(LegacyWineEntry oldData) { // Basic copy.... DTOMapper.CopyMembers(oldData, this); // Now the manual stuff..... Label = oldData.Name; Variety = oldData.Varietal; WineType = TranslateType(oldData.Type, oldData.Varietal); Qty = oldData.Bottles; BottleSize = oldData.Size; Best = oldData.PeakYear; UserNotes1 = oldData.TastingNotes; UserNotes2 = oldData.Notes + Environment.NewLine + oldData.ExtendedNotes; //RackNames = string.Join(" Location = oldData.Location; // + ", " + oldData.Position; UserField3 = oldData.Position; // This is how we will handle the racks.... if (oldData.Bottles == "1") { RackNames = "Rack 1"; RackCols = "1"; RackRows = "1"; } }
public void Edit(AccountInfoDTO EduDTO) { using (var container = new InventoryContainer()) { var Comp = new PayBankAccountInfo(); Comp = container.PayBankAccountInfoes.FirstOrDefault(o => o.AccountInfoId.Equals(EduDTO.AccountInfoId)); Comp.AccountInfoId = EduDTO.AccountInfoId; Comp.AccountName = EduDTO.AccountName; Comp.AccountNum = EduDTO.AccountNum; Comp.AccountTypeId = EduDTO.AccountTypeId; Comp.ActivationSatus = EduDTO.ActivationSatus; Comp.Address = EduDTO.Address; Comp.BankId = EduDTO.BankId; Comp.BranchName = EduDTO.BranchName; Comp.Mobile = EduDTO.Mobile; Comp.Phone = EduDTO.Phone; Comp.UpdateBy = EduDTO.UpdateBy; Comp.UpdateDate = EduDTO.UpdateDate; Comp.BrProId = EduDTO.BrProId; Comp = (PayBankAccountInfo)DTOMapper.DTOObjectConverter(EduDTO, Comp); container.SaveChanges(); } }
public async Task <IActionResult> Post([FromBody] ApplyFloristThemeAttributeDTO applyFloristThemeAttributeDTO) { ApplyFloristThemeAttributeModel ApplyFloristThemeAttributes = new DTOMapper <ApplyFloristThemeAttributeDTO, ApplyFloristThemeAttributeModel>().Serialize(applyFloristThemeAttributeDTO); var AppFloristThemeAttributesId = await _iThemeAttributesService.ApplyFloristThemeAttributes(ApplyFloristThemeAttributes); return(Ok(AppFloristThemeAttributesId)); }
internal OrderDetails GetSpecificOrder(string destination, string challanNumber) { List <List <Dictionary <String, string> > > persistentCarrier = new List <List <Dictionary <String, string> > >(); string query = "SELECT id FROM mlo.orders where destination = '" + destination + "' and challan_no='" + challanNumber + "'"; OrderDetails order = null; try { persistentCarrier = DBUtility.ExecuteQuery(query); SBMapper map = new SBMapper(); List <PropertyMap> listPropertyMap = PropertyMapper.MapOrderId(); map.MapperCollection = listPropertyMap; foreach (Dictionary <string, string> eachCarrier in persistentCarrier[0]) { order = new OrderDetails(); string json = new DTOMapper().Mapper(eachCarrier, order, map); //console.WriteLine("Destination = " + (json)); order = JsonConvert.DeserializeObject <OrderDetails>(json); } } catch (Exception ex) { throw ex; } return(order); }
public async Task <IActionResult> Post(DiscountDTO model) { DiscountModel discount = new DTOMapper <DiscountDTO, DiscountModel>().Serialize(model); var Response = await _discountService.AddDiscounts(discount); return(Ok(Response)); }
public async Task <IActionResult> Put(DiscountUpdateDTO model) { DiscountUpdateModel updatediscount = new DTOMapper <DiscountUpdateDTO, DiscountUpdateModel>().Serialize(model); var Response = await _discountService.UpdateDiscounts(updatediscount); return(Ok(Response)); }
internal List <Location> GetAllLocation() { Logger.Log(Level.Info, "Enter Get All Locations"); List <Location> locations = new List <Location>(); List <List <Dictionary <String, string> > > persistentCarrier = new List <List <Dictionary <String, string> > >(); try { String query = "SELECT * FROM mlo.location where updated = 'YES';"; persistentCarrier = DBUtility.ExecuteQuery(query); SBMapper map = new SBMapper(); map.MapperCollection = PropertyMapper.MapLocation(); Location loc = null; foreach (Dictionary <string, string> eachCarrier in persistentCarrier[0]) { loc = new Location(); string json = new DTOMapper().Mapper(eachCarrier, loc, map); loc = JsonConvert.DeserializeObject <Location>(json); locations.Add(loc); } } catch (Exception ex) { Logger.Log(Level.Error, "Error in Get All Locations :: " + ex.Message + "\n Caused By :- " + ex.StackTrace); throw ex; } return(locations); }
public async Task <IActionResult> Put([FromBody] RecipientUpdateStatusDTO recipientUpdateStatusDTO) { RecipientUpdateStatusModel RecipientUpdateStatus = new DTOMapper <RecipientUpdateStatusDTO, RecipientUpdateStatusModel>().Serialize(recipientUpdateStatusDTO); int RecipientUpdateStatusId = await _recipientService.RecipientsUpdateStatus(RecipientUpdateStatus); return(Ok(RecipientUpdateStatusId)); }
public async Task <IActionResult> Put([FromBody] RecipientUpdateDTO recipientUpdateDTO) { RecipientUpdateModel RecipientUpdate = new DTOMapper <RecipientUpdateDTO, RecipientUpdateModel>().Serialize(recipientUpdateDTO); int UpdateId = await _recipientService.UpdateRecipients(RecipientUpdate); return(Ok()); }
public async Task <IActionResult> Post(RecipientDTO model) { RecipientModel recipient = new DTOMapper <RecipientDTO, RecipientModel>().Serialize(model); var Response = await _recipientService.AddRecipients(recipient); return(Ok(Response)); }
public WebStoreCatalog SaveCatalog(WebStoreCatalog catalog) { // Map the seller id in the ambient context to the catalog parameter if (catalog.SellerId == 0) { catalog.SellerId = Context.SellerId; } using (var db = eCommerce.Accessors.EntityFramework.eCommerceDbContext.Create()) { EntityFramework.Catalog model = null; if (catalog.Id > 0) { model = db.Catalogs.Find(catalog.Id); // verify the db catalog belongs to the current seller and matches the catalog input seller if (model != null && (model.SellerId != catalog.SellerId || model.SellerId != Context.SellerId)) { Logger.Error("Seller Id mismatch"); throw new ArgumentException("Seller Id mismatch"); } DTOMapper.Map(catalog, model); } else { model = new EntityFramework.Catalog(); DTOMapper.Map(catalog, model); db.Catalogs.Add(model); } db.SaveChanges(); return(Find(model.Id)); } }
public DTO(Object x) { _mapper = new DTOMapper(); var dtoMethod = _mapper.GetType().GetMethod("GetDTOForEntity"); var dtosMethod = _mapper.GetType().GetMethod("GetDTOsForEntities"); var myProperties = this.GetType().GetProperties(); var xType = x.GetType(); foreach (var property in myProperties) { // Skip other DTOs for name, it will be handled later //if (property.PropertyType.FullName.Contains("DTO")) // continue; var xProperty = xType.GetProperty(property.Name, BindingFlags.Public | BindingFlags.Instance); var propertyType = property.PropertyType; if (xProperty != null && xProperty.CanRead) { var xValue = xProperty.GetValue(x, null); if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(ICollection<>) && IsDTO(propertyType)) { var generic = dtosMethod.MakeGenericMethod(xValue.GetType().GetGenericArguments()[0], propertyType.GetGenericArguments()[0]); xValue = generic.Invoke(_mapper, new object[] { xValue }); //continue; } else if (IsDTO(propertyType)) { var generic = dtoMethod.MakeGenericMethod(xValue.GetType(), propertyType); xValue = generic.Invoke(_mapper, new object[] {xValue}); } property.SetValue(this, xValue, null); } } }
public async Task <IActionResult> Post([FromBody] ThemeAttributesDTO themeAttributesDTO) { ThemeAttributesSaveModel SaveThemeAttributes = new DTOMapper <ThemeAttributesDTO, ThemeAttributesSaveModel>().Serialize(themeAttributesDTO); var ThemeAttributesId = await _iThemeAttributesService.AddFloristThemeAttributes(SaveThemeAttributes); return(Ok(ThemeAttributesId)); }
public async Task <IActionResult> Post([FromBody] PostThemeAttributeDTO postThemeAttributeDTO) { PostThemeAttributeModel FloristThemeAttributes = new DTOMapper <PostThemeAttributeDTO, PostThemeAttributeModel>().Serialize(postThemeAttributeDTO); var FloristThemeAttributesId = await _iThemeAttributesService.AddThemeAttributes(FloristThemeAttributes); return(Ok(FloristThemeAttributesId)); }
public async Task <IActionResult> Post([FromBody] ManageNoteDTO model) { ManageNoteModel Note = new DTOMapper <ManageNoteDTO, ManageNoteModel>().Serialize(model); var response = await _noteService.AddNotes(Note); return(Ok(response)); }
public async Task <List <TransactionsDTO> > GetTransactions() { try { //TODO: Add constants or resources file to avoid hardcoded strings var url = Configuration.GetValue <string>("AppSettings:UrlTransactions"); var result = await RequestHelper.GetListFromUrl <TransactionsDTO>(url); if (result != null && result.Any()) { //Save to DB var success = await SaveTransactionsToDB(result.Select(x => DTOMapper.TransactionDTO_To_Transaction(x)).ToList());; return(result); } else { var fromDB = _transactionsRepository.FindAll().Select(x => DTOMapper.Transaction_To_TransactionDTO(x)).ToList(); if (fromDB != null && fromDB.Any()) { return(fromDB.ToList()); } else { return(new List <TransactionsDTO>()); } } } catch (Exception ex) { LoggerHelper.LogError(ex.ToString()); return(new List <TransactionsDTO>()); } }
public async Task <IActionResult> Put([FromBody] UpdateProductCatalogDTO updateProductCatalogDTO) { UpdateProductCatalog productCatalogUpdate = new DTOMapper <UpdateProductCatalogDTO, UpdateProductCatalog>().Serialize(updateProductCatalogDTO); var updateCatalog = await _iProductCatalogService.UpdateProductCatalog(productCatalogUpdate); return(Ok(updateCatalog)); }
public async Task <IActionResult> Post(AddProductCatalogDTO model) { AddProductCatalog productCatalog = new DTOMapper <AddProductCatalogDTO, AddProductCatalog>().Serialize(model); var Response = await _iProductCatalogService.AddProductCatalog(productCatalog); return(Ok(Response)); }
public MyListWishController(DTOMapper dtoMapper, IUserIdProvider userIdProvider, IRepository<WishList> repository, IIdGenerator<Wish> idGenerator ) { _dtoMapper = dtoMapper; _userIdProvider = userIdProvider; _repository = repository; _idGenerator = idGenerator; }
public void Setup() { mapper = new DTOMapper(); }