// POST: api/servicelocation
 public IHttpActionResult Post([FromBody] ServiceLocationViewModel model)
 {
     try
     {
         var serviceLocation = new tblServiceLocation()
         {
             Name        = model.Name,
             Description = model.Description,
             Add1        = model.Add1,
             Add2        = model.Add2,
             City        = model.City,
             State       = model.State,
             Zip         = model.Zip,
             CountryId   = model.CountryId,
             Created     = DateTime.Now.ToUniversalTime(),
             IsActive    = model.IsActive,
             BusinessId  = model.BusinessId,
             TimezoneId  = model.TimezoneId
         };
         _db.tblServiceLocations.Add(serviceLocation);
         var response = _db.SaveChanges();
         if (response > 0)
         {
             return(Ok(new { status = true, data = serviceLocation }));
         }
         else
         {
             return(Ok(new { status = false, data = "There was a problem." }));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message.ToString()));
     }
 }
 // POST: api/businesshour
 public IHttpActionResult Post([FromBody] BusinessHolidayViewModel model)
 {
     try
     {
         if (model != null)
         {
             var busineessHoliday = new tblBusinessHoliday()
             {
                 OnDate            = model.OnDate,
                 Type              = model.Type,
                 ServiceLocationId = model.ServiceLocationId
             };
             _db.tblBusinessHolidays.Add(busineessHoliday);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = busineessHoliday }));
             }
             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()));
     }
 }
 // POST: api/Appointment
 public IHttpActionResult Post([FromBody] AppointmentViewModel model)
 {
     try
     {
         if (model != null)
         {
             var appointment = new tblAppointment()
             {
                 GlobalAppointmentId = model.GlobalAppointmentId,
                 BusinessServiceId   = model.BusinessServiceId,
                 Title              = model.Title,
                 PatternType        = model.PatternType,
                 StartTime          = model.StartTime,
                 EndTime            = model.EndTime,
                 IsRecuring         = model.IsRecuring,
                 IsAllDayEvent      = model.IsAllDayEvent,
                 TextColor          = model.TextColor,
                 BackColor          = model.BackColor,
                 RecureEvery        = model.RecureEvery,
                 EndAfter           = model.EndAfter,
                 EndAfterDate       = model.EndAfterDate,
                 StatusType         = model.StatusType,
                 CancelReason       = model.CancelReason,
                 IsActive           = model.IsActive,
                 Created            = model.Created,
                 BusinessCustomerId = model.BusinessCustomerId,
                 BusinessEmployeeId = model.BusinessEmployeeId,
                 BusinessOfferId    = model.BusinessOfferId,
                 ServiceLocationId  = model.ServiceLocationId
             };
             _db.tblAppointments.Add(appointment);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = appointment }));
             }
             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()));
     }
 }
예제 #4
0
 // POST: api/businessoffer
 public IHttpActionResult Post([FromBody] BusinessOfferViewModel model)
 {
     try
     {
         if (model != null)
         {
             if (model.ValidFrom > model.ValidTo)
             {
                 return(Ok(new { status = false, data = "", message = "Please provide a valid date from and to." }));
             }
             else if (model.ValidFrom.ToUniversalTime().Year < DateTime.UtcNow.Year || model.ValidTo.ToUniversalTime().Year < DateTime.UtcNow.Year)
             {
                 return(Ok(new { status = false, data = "", message = "Please provide a valid date from and to." }));
             }
             else
             {
                 var businessOffer = new tblBusinessOffer()
                 {
                     BusinessEmployeeId = model.BusinessEmployeeId,
                     Code        = model.Code,
                     Created     = DateTime.Now.ToUniversalTime(),
                     Description = model.Description,
                     IsActive    = true,
                     Name        = model.Name,
                     ValidFrom   = model.ValidFrom.ToUniversalTime(),
                     ValidTo     = model.ValidTo.ToUniversalTime()
                 };
                 _db.tblBusinessOffers.Add(businessOffer);
                 var response = _db.SaveChanges();
                 if (response > 0)
                 {
                     return(Ok(new { status = true, data = businessOffer, message = "success" }));
                 }
                 else
                 {
                     return(Ok(new { status = false, data = "", message = "There was a problem." }));
                 }
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "There was a problem." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = "ex: " + 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()));
     }
 }
        // POST: api/membership
        public IHttpActionResult Post([FromBody] MembershipViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
                    return(Ok(new { status = false, data = "", message = errMessage }));
                }

                var isAny = _db.tblMemberships.Any(d => d.Title.ToLower() == model.Title.ToLower());
                if (isAny)
                {
                    return(Ok(new { status = false, data = "", message = "please try another name." }));
                }

                var membership = new tblMembership()
                {
                    Created          = DateTime.Now.ToUniversalTime(),
                    Description      = model.Description,
                    IsActive         = model.IsActive,
                    Title            = model.Title,
                    Benifits         = model.Benifits,
                    IsUnlimited      = model.IsUnlimited,
                    Price            = model.Price,
                    TotalAppointment = model.TotalAppointment,
                    TotalCustomer    = model.TotalCustomer,
                    TotalEmployee    = model.TotalEmployee,
                    TotalLocation    = model.TotalLocation,
                    TotalOffers      = model.TotalLocation,
                    AdministratorId  = model.AdministratorId
                };
                _db.tblMemberships.Add(membership);
                var response = _db.SaveChanges();

                if (response > 0)
                {
                    return(Ok(new { status = true, data = membership, message = "success" }));
                }
                return(Ok(new { status = false, data = "", message = "failed" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
 // POST: api/AppointmentPayment
 public IHttpActionResult Post([FromBody] AppointmentPaymentViewModel model)
 {
     try
     {
         if (model != null)
         {
             var appointmentPayment = new tblAppointmentPayment()
             {
                 Amount           = model.Amount,
                 AppointmentId    = model.AppointmentId,
                 BillingType      = model.BillingType,
                 CardType         = model.CardType,
                 CCardNumber      = model.CCardNumber,
                 CCExpirationDate = model.CCExpirationDate,
                 CCFirstName      = model.CCFirstName,
                 CCLastName       = model.CCLastName,
                 CCSecurityCode   = model.CCSecurityCode,
                 ChequeNumber     = model.ChequeNumber,
                 Created          = (model.Created.HasValue == true) ? model.Created.Value.ToUniversalTime() : model.Created,
                 IsPaid           = model.IsPaid,
                 PaidDate         = model.PaidDate.ToUniversalTime(),
                 PurchaseOrderNo  = model.PurchaseOrderNo
             };
             _db.tblAppointmentPayments.Add(appointmentPayment);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = appointmentPayment }));
             }
             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()));
     }
 }
 // POST: api/businesshour
 public IHttpActionResult Post([FromBody] BusinessHourViewModel model)
 {
     try
     {
         if (model != null && model.From > DateTime.Now)
         {
             var businessHour = new tblBusinessHour()
             {
                 WeekDayId         = model.WeekDayId,
                 IsStartDay        = model.IsStartDay,
                 IsHoliday         = model.IsHoliday,
                 From              = model.From,
                 To                = model.To,
                 IsSplit1          = model.IsSplit1,
                 FromSplit1        = model.FromSplit1,
                 ToSplit1          = model.ToSplit1,
                 IsSplit2          = model.IsSplit2,
                 FromSplit2        = model.FromSplit2,
                 ToSplit2          = model.ToSplit2,
                 ServiceLocationId = model.ServiceLocationId
             };
             _db.tblBusinessHours.Add(businessHour);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessHour, message = "success" }));
             }
             else
             {
                 return(Ok(new { status = false, data = "", message = "There was a problem." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "Please enter a valid information." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = ex.Message.ToString() }));
     }
 }
예제 #9
0
        // POST: api/country
        public IHttpActionResult Post([FromBody] CountryViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
                    return(Ok(new { status = false, data = "", message = errMessage }));
                }

                var isAny = _db.tblCountries.Any(d => d.Name.ToLower() == model.Name.ToLower());
                if (isAny)
                {
                    return(Ok(new { status = false, data = "", message = "Please try another name." }));
                }

                var country = new tblCountry()
                {
                    Name            = model.Name,
                    CurrencyCode    = model.CurrencyCode,
                    CurrencyName    = model.CurrencyName,
                    ISO             = model.ISO,
                    ISO3            = model.ISO3,
                    PhoneCode       = model.PhoneCode.Value,
                    AdministratorId = model.AdministratorId,
                };

                _db.tblCountries.Add(country);
                var response = _db.SaveChanges();

                if (response > 0)
                {
                    return(Ok(new { status = true, data = country, message = "Transaction successed." }));
                }
                return(Ok(new { status = false, data = "", message = "Transaction failed." }));
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
 // POST: api/businessemployee
 public IHttpActionResult Post([FromBody] BusinessEmployeeViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessEmployee = new tblBusinessEmployee()
             {
                 FirstName         = model.FirstName,
                 LastName          = model.LastName,
                 LoginId           = model.LoginId,
                 Password          = Security.Encrypt(model.Password, true),
                 Email             = model.Email,
                 STD               = model.STD,
                 PhoneNumber       = model.PhoneNumber,
                 ServiceLocationId = model.ServiceLocationId,
                 IsAdmin           = model.IsAdmin,
                 Created           = DateTime.Now.ToUniversalTime(),
                 IsActive          = model.IsActive
             };
             _db.tblBusinessEmployees.Add(businessEmployee);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessEmployee }));
             }
             else
             {
                 return(Ok(new { status = false, data = "There was a problem." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "Model is not valid." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = ex.Message.ToString() }));
     }
 }
 // POST: api/businessofferservicelocation
 public IHttpActionResult Post([FromBody] BusinessOfferServiceLocationViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessOfferLocation = new tblBusinessOfferServiceLocation()
             {
                 BusinessOfferId   = model.BusinessOfferId,
                 ServiceLocationId = model.ServiceLocationId
             };
             var check = _db.tblBusinessOfferServiceLocations.Where(d => d.BusinessOfferId == model.BusinessOfferId && d.ServiceLocationId == model.ServiceLocationId).ToList();
             if (check.Count <= 0)
             {
                 _db.tblBusinessOfferServiceLocations.Add(businessOfferLocation);
                 var response = _db.SaveChanges();
                 if (response > 0)
                 {
                     return(Ok(new { status = true, data = businessOfferLocation, message = "success" }));
                 }
                 else
                 {
                     return(Ok(new { status = false, data = "", message = "There was a problem." }));
                 }
             }
             else
             {
                 return(Ok(new { status = false, data = "", message = "Offer has already linked with this offer. Try to link another location." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "There was a problem." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
     }
 }
 // POST: api/businesscategory
 public IHttpActionResult Post([FromBody] BusinessCategoryViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessCategory = new tblBusinessCategory()
             {
                 Created         = DateTime.Now.ToUniversalTime(),
                 Description     = model.Description,
                 IsActive        = model.IsActive,
                 Name            = model.Name,
                 OrderNumber     = model.OrderNumber,
                 ParentId        = model.ParentId,
                 PictureLink     = model.PictureLink,
                 Type            = model.Type,
                 AdministratorId = model.AdministratorId
             };
             _db.tblBusinessCategories.Add(businessCategory);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessCategory, message = "Transaction successed." }));
             }
             else
             {
                 return(Ok(new { status = false, data = "", message = "Transaction failed." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "Please provide a valid information." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
     }
 }
 // POST: api/businessoffer
 public IHttpActionResult Post([FromBody] BusinessOfferViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessOffer = new tblBusinessOffer()
             {
                 BusinessEmployeeId = model.BusinessEmployeeId,
                 Code        = model.Code,
                 Created     = model.Created,
                 Description = model.Description,
                 IsActive    = model.IsActive,
                 Name        = model.Name,
                 ValidFrom   = model.ValidFrom,
                 ValidTo     = model.ValidTo
             };
             _db.tblBusinessOffers.Add(businessOffer);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessOffer }));
             }
             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()));
     }
 }
 // POST: api/AppointmentFeedback
 public IHttpActionResult Post([FromBody] AppointmentFeedbackViewModel model)
 {
     try
     {
         if (model != null)
         {
             var appointmentFeedback = new tblAppointmentFeedback()
             {
                 BusinessCustomerId = model.BusinessCustomerId,
                 BusinessEmployeeId = model.BusinessEmployeeId,
                 Created            = (model.Created.HasValue) ? model.Created.Value.ToUniversalTime() : model.Created,
                 Feedback           = model.Feedback,
                 IsActive           = model.IsActive,
                 IsEmployee         = model.IsEmployee,
                 Rating             = model.Rating,
                 AppointmentId      = model.AppointmentId
             };
             _db.tblAppointmentFeedbacks.Add(appointmentFeedback);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = appointmentFeedback }));
             }
             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()));
     }
 }
 // POST: api/DocumentCategory
 public IHttpActionResult Post([FromBody] DocumentCategoryViewModel model)
 {
     try
     {
         if (model != null)
         {
             var documentCategory = new tblDocumentCategory()
             {
                 Created     = model.Created.ToUniversalTime(),
                 IsActive    = model.IsActive,
                 IsParent    = model.IsParent,
                 Name        = model.Name,
                 OrderNo     = model.OrderNo,
                 ParentId    = model.ParentId,
                 PictureLink = model.PictureLink,
                 Type        = model.Type
             };
             _db.tblDocumentCategories.Add(documentCategory);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = documentCategory }));
             }
             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()));
     }
 }
예제 #16
0
        // POST: api/timezone
        public IHttpActionResult Post([FromBody] TimezoneViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
                    return(Ok(new { status = false, data = "", message = errMessage }));
                }

                var isAny = _db.tblTimezones.Any(d => d.Title.ToLower() == model.Title.ToLower());
                if (isAny)
                {
                    return(Ok(new { status = false, data = "", message = "Please try another name." }));
                }

                var timeZone = new tblTimezone()
                {
                    Title           = model.Title,
                    IsDST           = model.IsDST,
                    UtcOffset       = model.UtcOffset,
                    CountryId       = model.CountryId,
                    AdministratorId = model.AdministratorId
                };
                _db.tblTimezones.Add(timeZone);
                var response = _db.SaveChanges();

                if (response > 0)
                {
                    return(Ok(new { status = true, data = timeZone, message = "Transaction successed." }));
                }
                return(Ok(new { status = false, data = "", message = "Transaction failed." }));
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
 // POST: api/businessemployee
 public IHttpActionResult Post([FromBody] BusinessEmployeeViewModel model)
 {
     try
     {
         if (model != null)
         {
             var check = _db.tblBusinessEmployees.Any(d => d.Email.ToLower() == model.Email.ToLower() && model.ServiceLocationId == model.ServiceLocationId);
             if (!check)
             {
                 var businessEmployee = new tblBusinessEmployee()
                 {
                     FirstName         = model.FirstName,
                     LastName          = model.LastName,
                     Password          = Security.Encrypt(model.Password, true),
                     Email             = model.Email,
                     STD               = model.STD,
                     PhoneNumber       = model.PhoneNumber,
                     ServiceLocationId = model.ServiceLocationId,
                     IsAdmin           = model.IsAdmin,
                     Created           = DateTime.Now.ToUniversalTime(),
                     IsActive          = model.IsActive
                 };
                 _db.tblBusinessEmployees.Add(businessEmployee);
                 var response = _db.SaveChanges();
                 if (response > 0)
                 {
                     return(Ok(new { status = true, data = businessEmployee, message = "success" }));
                 }
                 else
                 {
                     return(Ok(new { status = false, data = "", message = "There was a problem." }));
                 }
             }
             else
             {
                 return(Ok(new { status = false, data = "", message = "Email id has already been taken, please try another email id with same service location." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "Model is not valid." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = ex.Message.ToString() }));
     }
 }
        // POST: api/AppointmentInvitee
        public IHttpActionResult Post([FromBody] AppointmentInviteeViewModel model)
        {
            try
            {
                if (model != null)
                {
                    if (_db.tblAppointmentInvitees.Any(d => d.AppointmentId == model.AppointmentId && d.BusinessEmployeeId == model.BusinessEmployeeId))
                    {
                        return(Ok(new { status = false, data = "It's been already scheduled. Please try with other employee." }));
                    }

                    var appointmentInvitee = new tblAppointmentInvitee()
                    {
                        AppointmentId      = model.AppointmentId,
                        BusinessEmployeeId = model.BusinessEmployeeId
                    };
                    _db.tblAppointmentInvitees.Add(appointmentInvitee);
                    var response = _db.SaveChanges();
                    if (response > 0)
                    {
                        return(Ok(new { status = true, data = appointmentInvitee }));
                    }
                    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()));
            }
        }
예제 #19
0
 // POST: api/AppointmentDocument
 public IHttpActionResult Post([FromBody] AppointmentDocumentViewModel model)
 {
     try
     {
         if (model != null)
         {
             var appointmentDocument = new tblAppointmentDocument()
             {
                 AppointmentId      = model.AppointmentId,
                 DocumentCategoryId = model.DocumentCategoryId,
                 DocumentLink       = model.DocumentLink,
                 DocumentType       = model.DocumentType,
                 Title            = model.Title,
                 IsEmployeeUpload = model.IsEmployeeUpload
             };
             _db.tblAppointmentDocuments.Add(appointmentDocument);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = appointmentDocument }));
             }
             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()));
     }
 }
예제 #20
0
 // POST: api/businessservice
 public IHttpActionResult Post([FromBody] BusinessServiceViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessService = new tblBusinessService()
             {
                 Name        = model.Name,
                 Description = model.Description,
                 Cost        = model.Cost,
                 IsActive    = model.IsActive,
                 Created     = model.Created,
                 EmployeeId  = model.EmployeeId
             };
             _db.tblBusinessServices.Add(businessService);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessService }));
             }
             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()));
     }
 }
예제 #21
0
 // POST: api/business
 public IHttpActionResult Post([FromBody] BusinessViewModel model)
 {
     try
     {
         if (model != null)
         {
             var business = new tblBusiness()
             {
                 Name               = model.Name,
                 ShortName          = model.ShortName,
                 IsInternational    = model.IsInternational,
                 FaxNumbers         = model.FaxNumbers,
                 PhoneNumbers       = model.PhoneNumbers,
                 Logo               = model.Logo,
                 Add1               = model.Add1,
                 Add2               = model.Add2,
                 City               = model.City,
                 State              = model.State,
                 CountryId          = model.CountryId,
                 Email              = model.Email,
                 Website            = model.Website,
                 Created            = DateTime.Now.ToUniversalTime(),
                 IsActive           = model.IsActive,
                 Zip                = model.Zip,
                 MembershipId       = model.MembershipId,
                 BusinessCategoryId = model.BusinessCategoryId,
                 TimezoneId         = model.TimezoneId
             };
             _db.tblBusinesses.Add(business);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = business }));
             }
             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()));
     }
 }
예제 #22
0
        // POST: api/administrator
        public IHttpActionResult Post([FromBody] AdministratorViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
                    return(Ok(new { status = false, data = "", message = errMessage }));
                }

                var isAny = _db.tblAdministrators.Any(d => d.Email.ToLower() == model.Email.ToLower());
                if (isAny)
                {
                    return(Ok(new { status = false, data = "", message = "Please try another email id." }));
                }

                var admin = new tblAdministrator()
                {
                    Email           = model.Email,
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    LoginId         = model.LoginId,
                    Password        = Security.Encrypt(model.Password, true),
                    IsAdmin         = model.IsAdmin,
                    IsActive        = model.IsActive,
                    ContactNumber   = model.ContactNumber,
                    Created         = DateTime.Now.ToUniversalTime(),
                    AdministratorId = model.AdministratorId,
                };

                _db.tblAdministrators.Add(admin);
                var response = _db.SaveChanges();

                if (response > 0)
                {
                    return(Ok(new { status = true, data = admin, message = "Transaction successed." }));
                }
                return(Ok(new { status = false, data = "", message = "Transaction failed." }));
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
예제 #23
0
        // POST: api/servicelocation
        public IHttpActionResult Post([FromBody] ServiceLocationViewModel model)
        {
            try
            {
                var serviceLocation = new tblServiceLocation()
                {
                    Name        = model.Name,
                    Description = model.Description,
                    Add1        = model.Add1,
                    Add2        = model.Add2,
                    City        = model.City,
                    State       = model.State,
                    Zip         = model.Zip,
                    CountryId   = model.CountryId,
                    Created     = DateTime.Now.ToUniversalTime(),
                    IsActive    = model.IsActive,
                    BusinessId  = model.BusinessId,
                    TimezoneId  = model.TimezoneId
                };

                using (var dbTrans = _db.Database.BeginTransaction())
                {
                    _db.tblServiceLocations.Add(serviceLocation);
                    var responseLocation = _db.SaveChanges();

                    var today = DateTime.Now;
                    var date  = new DateTime(today.Year, today.Month, today.Day, 8, 00, 00, DateTimeKind.Utc);
                    for (int i = 0; i < 7; i++)
                    {
                        var businessHour = new tblBusinessHour()
                        {
                            WeekDayId         = i,
                            IsStartDay        = i == 0 ? true : false,
                            IsHoliday         = false,
                            From              = date,
                            To                = date.AddHours(10),
                            IsSplit1          = false,
                            FromSplit1        = null,
                            ToSplit1          = null,
                            IsSplit2          = false,
                            FromSplit2        = null,
                            ToSplit2          = null,
                            ServiceLocationId = serviceLocation.Id
                        };
                        _db.tblBusinessHours.Add(businessHour);
                    }
                    var responseHour = _db.SaveChanges();
                    if (responseHour > 0 && responseLocation > 0)
                    {
                        dbTrans.Commit();
                        return(Ok(new { status = true, data = serviceLocation, message = "success" }));
                    }
                    else
                    {
                        dbTrans.Rollback();
                        return(Ok(new { status = false, data = "", message = "There was a problem." }));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = ex.Message.ToString() }));
            }
        }