// PUT: api/BusinessCustomer/5
        public IHttpActionResult Put(long?id, [FromBody] BusinessCustomerViewMdoel model)
        {
            try
            {
                if (!id.HasValue)
                {
                    return(Ok(new { status = false, data = "Please provide a valid ID." }));
                }
                else
                {
                    if (model != null)
                    {
                        var businessCustomer = _db.tblBusinessCustomers.Find(id);
                        if (businessCustomer != null)
                        {
                            businessCustomer.FirstName         = model.FirstName;
                            businessCustomer.LastName          = model.LastName;
                            businessCustomer.ProfilePicture    = model.ProfilePicture;
                            businessCustomer.Email             = model.Email;
                            businessCustomer.StdCode           = model.StdCode;
                            businessCustomer.PhoneNumber       = model.PhoneNumber;
                            businessCustomer.Add1              = model.Add1;
                            businessCustomer.Add2              = model.Add2;
                            businessCustomer.City              = model.City;
                            businessCustomer.State             = model.State;
                            businessCustomer.Zip               = model.Zip;
                            businessCustomer.LoginId           = model.LoginId;
                            businessCustomer.Password          = model.Password;
                            businessCustomer.IsActive          = model.IsActive;
                            businessCustomer.Created           = model.Created;
                            businessCustomer.TimezoneId        = model.TimezoneId;
                            businessCustomer.ServiceLocationId = model.ServiceLocationId;

                            _db.Entry(businessCustomer).State = EntityState.Modified;
                            var response = _db.SaveChanges();
                            if (response > 0)
                            {
                                return(Ok(new { status = true, data = businessCustomer }));
                            }
                            else
                            {
                                return(Ok(new { status = false, data = "There was a problem to update the data." }));
                            }
                        }
                    }
                    return(Ok(new { status = false, data = "Not a valid data to update. Please provide a valid id." }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message.ToString()));
            }
        }
 // POST: api/BusinessCustomer
 public IHttpActionResult Post([FromBody] BusinessCustomerViewMdoel model)
 {
     try
     {
         if (model != null)
         {
             var businessCustomer = new tblBusinessCustomer()
             {
                 FirstName         = model.FirstName,
                 LastName          = model.LastName,
                 ProfilePicture    = model.ProfilePicture,
                 Email             = model.Email,
                 StdCode           = model.StdCode,
                 PhoneNumber       = model.PhoneNumber,
                 Add1              = model.Add1,
                 Add2              = model.Add2,
                 City              = model.City,
                 State             = model.State,
                 Zip               = model.Zip,
                 LoginId           = model.LoginId,
                 Password          = model.Password,
                 IsActive          = model.IsActive,
                 Created           = model.Created,
                 TimezoneId        = model.TimezoneId,
                 ServiceLocationId = model.ServiceLocationId
             };
             _db.tblBusinessCustomers.Add(businessCustomer);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessCustomer }));
             }
             else
             {
                 return(Ok(new { status = false, data = "There was a problem." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "There was a problem." }));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message.ToString()));
     }
 }
        public ResponseViewModel <BusinessCustomerViewMdoel> Register(BusinessCustomerViewMdoel model)
        {
            var data     = new ResponseViewModel <BusinessCustomerViewMdoel>();
            var hasEmail = _db.tblBusinessCustomers.Any(d => d.Email.ToLower() == model.Email.ToLower() && d.ServiceLocationId == model.ServiceLocationId);

            if (hasEmail)
            {
                data.Status  = false;
                data.Message = "This business email has been taken. Please try another email id.";
            }
            else
            {
                var businessCustomer = new tblBusinessCustomer()
                {
                    FirstName         = model.FirstName,
                    LastName          = model.LastName,
                    Password          = Security.Encrypt(model.Password, true),
                    Email             = model.Email,
                    StdCode           = model.StdCode,
                    IsActive          = model.IsActive,
                    PhoneNumber       = model.PhoneNumber,
                    Add1              = model.Add1,
                    Add2              = model.Add2,
                    City              = model.City,
                    ProfilePicture    = model.ProfilePicture,
                    State             = model.State,
                    Zip               = model.Zip,
                    Created           = DateTime.Now.ToUniversalTime(),
                    ServiceLocationId = model.ServiceLocationId
                };
                _db.tblBusinessCustomers.Add(businessCustomer);
                var response = _db.SaveChanges();
                data.Message = response > 0 ? "success" : "failed";
                data.Status  = response > 0 ? true : false;
                data.Data    = model;
            }
            return(data);
        }