public BusinessDataModel Get(BusinessDTO modelDTO) { BusinessDataModel BusinessDataModel = null; if (modelDTO != null) { //List<BusinessAddressDTO> BusinessAddressDTO = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.Select(p => p) : null; //AddressDTO oPrimaryAddressDTO = (BusinessAddressDTO != null) ? BusinessAddressDTO.Addres : null; List <AddressDTO> oPrimaryAddressDTO = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.Where(p => p.BusinessID == modelDTO.BusinessID).Select(p => p.Addres).ToList() : null; List <ServiceDTO> servicesList = (modelDTO.Services != null) ? modelDTO.Services.Where(p => p.BusinessID == modelDTO.BusinessID).ToList() : null; List <AchievementDTO> oPrimaryAchievementDTO = (modelDTO.Achievements != null) ? modelDTO.Achievements.Where(p => p.BusinessID == modelDTO.BusinessID).Select(p => p).ToList() : null; BusinessPhoneDTO BusinessPhoneDTO = (modelDTO.BusinessPhones != null) ? modelDTO.BusinessPhones.Where(o => o.IsPrimary).FirstOrDefault() : null; PhoneDTO oPrimaryPhoneDTO = (BusinessPhoneDTO != null) ? BusinessPhoneDTO.Phone : null; //BusinessImageDTO BusinessImageDTO = (modelDTO.BusinessImages != null) ? modelDTO.BusinessImages.Where(o => o.IsPrimary).FirstOrDefault() : null; //ImageDTO oPrimaryImageDTO = (BusinessImageDTO != null) ? BusinessImageDTO.Image : null; ImageDTO oPrimaryImageDTO = (modelDTO.BusinessImages != null) ? modelDTO.BusinessImages.Where(o => o.IsPrimary).Select(p => p.Image).FirstOrDefault() : null; BusinessEmailDTO BusinessEmailDTO = (modelDTO.BusinessEmails != null) ? modelDTO.BusinessEmails.Where(o => o.IsPrimary).FirstOrDefault() : null; EmailDTO oPrimaryEmailDTO = (BusinessEmailDTO != null) ? BusinessEmailDTO.Email : null; BusinessDataModel = BusinessDataModelAssembler.ToDataModel(modelDTO, oPrimaryAddressDTO, oPrimaryPhoneDTO, oPrimaryEmailDTO, oPrimaryImageDTO, oPrimaryAchievementDTO, null, servicesList); BusinessDataModel.PrimaryAddressID = (modelDTO.BusinessAddresses != null) ? modelDTO.BusinessAddresses.FirstOrDefault(p => p.IsPrimary == true).AddressID : 0; //BusinessDataModel.BusinessAddressID = (BusinessAddressDTO != null) ? BusinessAddressDTO.BusinessAddressID : 0; BusinessDataModel.BusinessPhoneID = (BusinessPhoneDTO != null) ? BusinessPhoneDTO.BusinessPhoneID : 0; BusinessDataModel.BusinessEmailID = (BusinessEmailDTO != null) ? BusinessEmailDTO.BusinessEmailID : 0; } return(BusinessDataModel); }
public async Task <IActionResult> AddEvents([FromBody] BusinessDTO model) { var email = (await _userManager.GetUserAsync(HttpContext.User)).Email; var user = await _userRepository.FindByEmail(email); var business = user.Business; if (business == null) { return(Unauthorized()); } if (business.Events != null) { await _eventRepository.RemoveMultiple(business.Events); } business.Events = new List <Event>(); await _businessRepository.SaveChanges(); foreach (var ev in model.Events) { business.Events.Add(new Event() { Name = ev.Name, Description = ev.Description, Type = ev.Type, Creation = ev.Creation }); } await _businessRepository.SaveChanges(); return(Ok()); }
public static BusinessDTO NewBusiness(BusinessDTO b) { Business__tbl budal = BusinessDTO.ToDAL(b); Business__tbl btbl = DAL.BusinessDAL.NewBusiness(budal); return(new BusinessDTO(btbl)); }
public static List <BusinessDTO> GetBusinessByCategoryCode(int code) { List <Business__tbl> busniessListDal = DAL.BusinessDAL.GetBusinessByCategoryCode(code); List <BusinessDTO> busniessDTOs = BusinessDTO.ListToDTO(busniessListDal); return(busniessDTOs); }
public static List <BusinessDTO> GetBusinessByOwnerCode(string code) { List <Business__tbl> busniessListDal = DAL.BusinessDAL.GetBusinessByOwnerCode(code); List <BusinessDTO> busniessDTOs = BusinessDTO.ListToDTO(busniessListDal); return(busniessDTOs); }
public static List <BusinessDTO> GetAllBusiness() { List <Business__tbl> busniessListDal = DAL.BusinessDAL.GetAllBusiness(); List <BusinessDTO> busniessDTOs = BusinessDTO.ListToDTO(busniessListDal); return(busniessDTOs); }
/// <summary> /// Converts this instance of <see cref="Business"/> to an instance of <see cref="BusinessDTO"/>. /// </summary> /// <param name="entity"><see cref="Business"/> to convert.</param> public static BusinessDTO ToDTO(this Business entity) { if (entity == null) { return(null); } var dto = new BusinessDTO(); dto.BusinessID = entity.BusinessID; dto.Name = entity.Name; dto.Abbreviation = entity.Abbreviation; dto.StartDate = entity.StartDate; dto.BusinessTypeID = entity.BusinessTypeID; dto.IsActive = entity.IsActive; dto.IsDeleted = entity.IsDeleted; dto.insuser = entity.insuser; dto.insdt = entity.insdt; dto.upduser = entity.upduser; dto.upddt = entity.upddt; entity.OnDTO(dto); return(dto); }
// // GET: /Business/Edit/5 public ActionResult Edit(Guid id) { BusinessDTO businessDTO = GetBusiness(id); if (businessDTO == null) { return(HttpNotFound()); } else { BusinessDetailsDTO busDetailsDTO = MapperFacade.MapperConfiguration.Map <BusinessDTO, BusinessDetailsDTO>(businessDTO); ViewBag.SelIndustry = businessDTO.TypeIndustry; ViewBag.Industries = (from BusinessTypeDTO type in this.GetBusinessTypes() select type.Industry).Distinct().ToList(); ViewBag.SelBusTypeId = businessDTO.TypeId; if (!String.IsNullOrEmpty(businessDTO.TypeIndustry)) { ViewBag.BusinesTypeDetails = this.GetBusinessTypes().Where(t => t.Industry == businessDTO.TypeIndustry); } return(PartialView(busDetailsDTO)); } }
public BussinessDataModel CreateBusiness(BussinessDataModel businessDataModel) { if (businessDataModel != null) { BusinessDTO businessDTO = new BusinessDTO(); AddressDTO addressDTO = new AddressDTO(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); businessDTO = BussinessDataModelAssembler.ToBusinessDTO(businessDataModel); phoneDTO = BussinessDataModelAssembler.ToPhoneDTO(businessDataModel); emailDTO = BussinessDataModelAssembler.ToEmailDTO(businessDataModel); addressDTO = BussinessDataModelAssembler.ToAddressDTO(businessDataModel); if (businessDTO != null) { businessDTO = businessBL.Create(businessDTO); } if (phoneDTO != null) { phoneDTO = phonesBL.Create(phoneDTO); } if (emailDTO != null) { emailsBL.Create(emailDTO); } if (addressDTO != null) { addressBL.Create(addressDTO); } } return(businessDataModel); }
public List <RoleDTO> GetBusinessRoles(Guid id, HttpSessionStateBase session = null) { BusinessDTO businessDTO = GetBusiness(id, session); //Only return enabled roles return(businessDTO.Roles.Where(r => r.Enabled).ToList()); }
public async Task <BusinessDTO> GetByID(int BusinessID) { var businessResponse = await _repositoryContext.Business.Where(a => a.ID == BusinessID).FirstOrDefaultAsync(); var orderdetails = await _repositoryContext.Order. Where(ord => ord.BusinessID == businessResponse.ID) .ToListAsync(); var orderDetailsDto = orderdetails.Select(a => new OrderDTO { ID = a.ID, Description = a.Description, Date = a.Date.ToString(), Discount = a.Discount, InvoiceNumber = a.InvoiceNumber, OrderPlatform = a.OrderPlatform, Status = a.Status }).ToList(); var result = new BusinessDTO { Name = businessResponse.Name, Description = businessResponse.Description, Email = businessResponse.Email, Industry = businessResponse.Industry, Phone = businessResponse.Phone }; return(result); }
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="BusinessDTO"/> converted from <see cref="Business"/>.</param> static partial void OnDTO(this Business entity, BusinessDTO dto) { if (entity.BusinessAddresses != null && entity.BusinessAddresses.Count > 0) { dto.BusinessAddresses = BusinessAddressAssembler.ToDTOs(entity.BusinessAddresses.ToList()); } if (entity.BusinessEmails != null && entity.BusinessEmails.Count > 0) { dto.BusinessEmails = BusinessEmailAssembler.ToDTOs(entity.BusinessEmails); } if (entity.BusinessImages != null && entity.BusinessImages.Count > 0) { dto.BusinessImages = BusinessImageAssembler.ToDTOs(entity.BusinessImages); } if (entity.Achievements != null && entity.Achievements.Count > 0) { dto.Achievements = AchievementAssembler.ToDTOs(entity.Achievements); } if (entity.BusinessImages != null && entity.BusinessImages.Count > 0) { dto.BusinessImages = BusinessImageAssembler.ToDTOs(entity.BusinessImages); } if (entity.BusinessPhones != null && entity.BusinessPhones.Count > 0) { dto.BusinessPhones = BusinessPhoneAssembler.ToDTOs(entity.BusinessPhones); } }
public BusinessDataModel Get(int id) { BusinessDataModel businessDataModel = null; if (id > 0) { BusinessDTO businessDTO = businessBL.Get(id); if (businessDTO != null) { businessDataModel = Get(businessDTO); if (businessDataModel != null) { businessDataModel.BusinessServices = new ServiceBL().Get().Where(p => p.BusinessID == businessDataModel.BusinessID).ToList(); } var businessUsers = new BusinessUserMapBL().Get().Where(p => p.BusinessID == id && p.IsOwner == true).FirstOrDefault(); if (businessUsers != null) { businessDataModel.Owner = new UsersBL().Get(businessUsers.UserID); } } } return(businessDataModel); }
/// <summary> /// Converts this instance of <see cref="BusinessDTO"/> to an instance of <see cref="Business"/>. /// </summary> /// <param name="dto"><see cref="BusinessDTO"/> to convert.</param> public static Business ToEntity(this BusinessDTO dto) { if (dto == null) { return(null); } var entity = new Business(); entity.BusinessID = dto.BusinessID; entity.Name = dto.Name; entity.Abbreviation = dto.Abbreviation; entity.StartDate = dto.StartDate; entity.BusinessTypeID = dto.BusinessTypeID; entity.IsActive = dto.IsActive; entity.IsDeleted = dto.IsDeleted; entity.insuser = dto.insuser; entity.insdt = dto.insdt; entity.upduser = dto.upduser; entity.upddt = dto.upddt; dto.OnEntity(entity); return(entity); }
public BusinessDataModel Update(BusinessDataModel dataModel) { if (dataModel != null) { BusinessDTO businessDTO = new BusinessDTO(); List <AddressDTO> addressDTO = new List <AddressDTO>(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); BusinessUserMapDTO businessUserMapDTO = new BusinessUserMapDTO(); businessDTO = BusinessDataModelAssembler.ToBusinessDTO(dataModel); phoneDTO = BusinessDataModelAssembler.ToPhoneDTO(dataModel); emailDTO = BusinessDataModelAssembler.ToEmailDTO(dataModel); addressDTO = BusinessDataModelAssembler.ToAddressDTO(dataModel); businessUserMapDTO = BusinessDataModelAssembler.ToBusinessUserMapDTO(dataModel); if (businessDTO != null) { businessDTO = businessBL.Update(businessDTO); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (phoneDTO != null) { phoneDTO = phonesBL.Update(phoneDTO); } new BusinessPhoneBL().Update(new BusinessPhoneDTO() { BusinessID = dataModel.BusinessID, BusinessPhoneID = dataModel.BusinessPhoneID, IsPrimary = true }); dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (emailDTO != null) { emailDTO = emailsBL.Update(emailDTO); } new BusinessEmailBL().Update(new BusinessEmailDTO() { BusinessID = dataModel.BusinessID, BusinessEmailID = dataModel.BusinessEmailID, IsPrimary = true }); dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); if (addressDTO != null) { addressDTO = addressDTO.Select(p => addressBL.Update(p)).ToList(); } dataModel = BusinessDataModelAssembler.ToDataModel(businessDTO, addressDTO, phoneDTO, emailDTO, null, null, businessUserMapDTO, null); new BusinessAddressBL().Update(new BusinessAddressDTO() { BusinessID = dataModel.BusinessID, BusinessAddressID = dataModel.BusinessAddressID, IsPrimary = true }); } return(dataModel); }
public BusinessDTO GetBusiness(int businessID) { bool lockWasTaken = false; BusinessDTO businessDTO = null; using (RampUpProjectEntities dbContext = new RampUpProjectEntities(rampConnectionString)) { try { Monitor.Enter(dbContext, ref lockWasTaken); Business business = dbContext.Businesses.Where(x => x.Business_Id == businessID).FirstOrDefault(); if (business != null) { businessDTO = ConvertBusinessToBusinessDTO(business); } if (lockWasTaken) { Monitor.Exit(dbContext); lockWasTaken = false; } } catch (Exception) { if (lockWasTaken) { Monitor.Exit(dbContext); lockWasTaken = false; } throw; } return(businessDTO); } }
public BusinessDTO Create(BusinessDTO modelDTO) { if (modelDTO != null) { return(BusinessAssembler.ToDTO(businessRepo.CreateBusiness(BusinessAssembler.ToEntity(modelDTO)))); } return(null); }
// // GET: /Business/BusinessLocationIndex/5 public ActionResult BusinessLocationIndex(Guid businessid) { ViewBag.BusinessId = businessid; BusinessDTO businessDTO = GetBusiness(businessid); ViewBag.BusinessName = businessDTO.Name; return(View(businessDTO.BusinessLocations)); }
private static Business ConvertBusinessDTOToBusiness(BusinessDTO businessDTO) { return(new Business { Business_Id = businessDTO.Business_Id, Name = businessDTO.Name, Creation_Date = businessDTO.Creation_Date, User_Id = businessDTO.User_Id }); }
public IHttpActionResult NewBusiness(BusinessDTO b) { BusinessDTO business = BL.BusniessBL.NewBusiness(b); if (business != null) { return(Ok(business)); } return(Ok(false)); }
// // GET: /Business/Delete/5 public ActionResult Delete(Guid id) { BusinessDTO businessDTO = GetBusiness(id); if (businessDTO == null) { return(HttpNotFound()); } return(View(businessDTO)); }
//[HttpPost] //public PartialViewResult AddInternalLocation(InternalLocation intLocation, int index) //{ // List<InternalLocationDTO> internalLocations = new List<InternalLocationDTO>(); // for (int i = 0; i < index; i++) // { // internalLocations.Add(null); // } // internalLocations.Add(new InternalLocationDTO()); // ViewBag.Index = index; // var model = new BusinessRegisterDTO // { // InternalLocations = internalLocations // }; // return PartialView("InternalLocationDTO", model); //} // // GET: /Business/Details/5 public ActionResult Details(Guid id) { BusinessDTO businessDTO = GetBusiness(id); if (businessDTO == null) { return(HttpNotFound()); } return(PartialView(businessDTO)); }
public IHttpActionResult UpdateBusiness([FromBody] BusinessDTO businessDTO) { if (businessDTO == null) { return(BadRequest("BusinessDTO cannot be null")); } businessSvc.UpdateBusiness(businessDTO); return(Ok()); }
public IHttpActionResult AddBusiness([FromBody] BusinessDTO businessToAdd) { try { return(Ok(BusinessBL.AddBusiness(businessToAdd))); } catch { return(BadRequest()); } }
public static BussinessDataModel ToDataModel(BusinessDTO bussinessDTO, AddressDTO primaryAddressDTO, PhoneDTO primaryPhoneDTO, EmailDTO primaryEmailDTO) { BussinessDataModel model = null; if (model != null) { model = new BussinessDataModel(); model.Abbreviation = bussinessDTO.Abbreviation; model.BusinessID = bussinessDTO.BusinessID; model.BusinessTypeID = bussinessDTO.BusinessTypeID; model.insdt = bussinessDTO.insdt; model.insuser = bussinessDTO.insuser; model.IsActive = bussinessDTO.IsActive; model.IsDeleted = bussinessDTO.IsDeleted; model.Name = bussinessDTO.Name; model.StartDate = bussinessDTO.StartDate; model.upddt = bussinessDTO.upddt; model.upduser = bussinessDTO.upduser; } if (primaryAddressDTO != null) { model.BusinessAddressAddressTypeID = primaryAddressDTO.AddressTypeID; model.BusinessAddressCity = primaryAddressDTO.City; model.BusinessAddressCountryID = primaryAddressDTO.CountryID; model.BusinessAddressID = primaryAddressDTO.AddressID; model.BusinessAddressLine1 = primaryAddressDTO.Line1; model.BusinessAddressLine2 = primaryAddressDTO.Line2; model.BusinessAddressLine3 = primaryAddressDTO.Line3; model.BusinessAddressState = primaryAddressDTO.State; model.BusinessAddressTitle = primaryAddressDTO.Title; model.BusinessAddressZipCode = primaryAddressDTO.ZipCode; } if (primaryPhoneDTO != null) { model.BusinessPhoneCountryID = primaryPhoneDTO.CountryID; model.BusinessPhoneExt = primaryPhoneDTO.Ext; model.BusinessPhoneID = primaryPhoneDTO.PhoneID; model.BusinessPhoneNumber = primaryPhoneDTO.Number; model.BusinessPhoneTypeID = primaryPhoneDTO.PhoneTypeID; } if (primaryEmailDTO != null) { model.BusinessEmailAddress = primaryEmailDTO.Address; model.BusinessEmailID = primaryEmailDTO.EmailID; model.BusinessEmailTypeID = primaryEmailDTO.EmailTypeID; } return(model); }
public IHttpActionResult GetBusiness(int?businessID) { if (businessID == null || businessID == 0) { return(BadRequest("BusinessID cannot be null")); } BusinessDTO business = businessSvc.GetBusiness((int)businessID); return(Ok(business)); }
public IHttpActionResult AddBusiness([FromBody] BusinessDTO businessDTO) { if (businessDTO == null) { return(BadRequest("BusinessDTO cannot be null")); } int businessID = businessSvc.AddBusiness(businessDTO); return(Ok(businessID)); }
public static Business BusinessDTOToBusiness(BusinessDTO dto) { return(new Business() { Name = dto.Name, Address = AddressMapper.AddressDTOToAddress(dto.Address), Phone = dto.Phone, Email = dto.Email, OperationalHour = dto.OperationalHour }); }
public BusinessDTO Update(BusinessDTO modelDTO) { BusinessDTO returnBusiness = null; if (modelDTO != null && modelDTO.BusinessID > 0) { businessRepo.UpdateBusiness(BusinessAssembler.ToEntity(modelDTO)); returnBusiness = modelDTO; } return(returnBusiness); }
public BusinessDTO Update(BusinessDTO oBusinessDTO) { BusinessDTO returnBusiness = null; if (oBusinessDTO != null && oBusinessDTO.BusinessID > 0) { oBusinessRepo.UpdateBusiness(BusinessAssembler.ToEntity(oBusinessDTO)); returnBusiness = oBusinessDTO; } return(returnBusiness); }