public Customer AddTypeBusiness(CustomerRegisterViewModel model, Guid idAccount) { var customer = Save(model, idAccount); var typeBusiness = new TypeBusiness() { IdAccount = idAccount, IdCustomer = customer.Id, Name = model.NewTypeBusiness, StatusRegister = CStatusRegister.Active }; _typeBusinessDao.InsertOrUpdate(typeBusiness); return(customer); }
public async Task <bool> EditAsync( int id, string name, TypeBusiness type, string webPageUrl, string address, double latLocation, double lngLocation, IEnumerable <PetType> petTypes, string city, string picUrl, bool isApproved, string note, string authorId) { var business = await this.db.Businesses.FirstOrDefaultAsync(b => b.Id == id); if (business == null) { return(false); } business.Name = name; business.Type = type; business.WebPageUrl = webPageUrl; business.Address = address; business.LatLocation = latLocation; business.LngLocation = lngLocation; business.PetType = (PetType)petTypes.Cast <int>().Sum(); business.City = city; business.PicUrl = picUrl; business.IsApproved = isApproved; business.Note = note; this.db.SaveChanges(); return(true); }
public async Task <int> CreateAsync( string name, TypeBusiness type, string webPageUrl, string address, double latLocation, double lngLocation, IEnumerable <PetType> petTypes, string city, string picUrl, bool isApproved, string note, string authorId) { var business = new Business() { Name = name, Type = type, WebPageUrl = webPageUrl, Address = address, LatLocation = latLocation, LngLocation = lngLocation, PetType = (PetType)petTypes.Cast <int>().Sum(), City = city, PicUrl = picUrl, IsApproved = isApproved, Note = note, PublishDate = DateTime.UtcNow, AuthorId = authorId }; this.db.Add(business); await this.db.SaveChangesAsync(); return(business.Id); }
public void Setup(bool isNew) { var businessTypeHandler = new BusinessTypeHandler(); var usaStatesHandler = new UsaStatesHandler(); var streetAddressTypeHandler = new StreetAddressTypeHandler(); var emailTypeHandler = new EmailTypeHandler(); var phoneNumberTypeHandler = new PhoneNumberTypeHandler(); var emailTypes = emailTypeHandler.ReadAll(); var phoneNumberTypes = phoneNumberTypeHandler.ReadAll(); TypeBusinessList = businessTypeHandler.ReadAll().ToSelectListItems(TypeBusiness.IsNullOrEmpty() ? "" : TypeBusiness); if (isNew || Base.Addresses.Count == 0) { // add one default address Base.BuildAddresses(); } foreach (var address in Base.Addresses) { address.AddressStateList = usaStatesHandler.ReadAll().ToSelectListItems(address.StateID.IsNullOrEmpty() ? "TX" : address.StateID); //primary address.AddressTypeList = streetAddressTypeHandler.ReadAll().ToSelectListItems(address.Type.IsNullOrEmpty() ? "1" : address.Type); } if (isNew || Base.EmailAddresses.Count == 0) { // add two default email addresses Base.BuildEmailAddresses(2); //work Base.EmailAddresses[0].EmailTypeList = emailTypes.ToSelectListItems("2"); //other Base.EmailAddresses[1].EmailTypeList = emailTypes.ToSelectListItems("4"); } else { foreach (var email in Base.EmailAddresses) { email.EmailTypeList = emailTypes.ToSelectListItems(email.Type); } } if (isNew || Base.PhoneNumbers.Count == 0) { // add three default phone numbers Base.BuildPhoneNumbers(3); //work Base.PhoneNumbers[0].PhoneNumberTypeList = phoneNumberTypes.ToSelectListItems("2"); //mobile Base.PhoneNumbers[1].PhoneNumberTypeList = phoneNumberTypes.ToSelectListItems("3"); //fax Base.PhoneNumbers[2].PhoneNumberTypeList = phoneNumberTypes.ToSelectListItems("4"); } else { foreach (var phone in Base.PhoneNumbers) { phone.PhoneNumberTypeList = phoneNumberTypes.ToSelectListItems(phone.Type); } } }