Esempio n. 1
0
        public JsonResult GetClinic(int id)
        {
            var clinic     = _manager.GetById(id);
            var clinicItem = new ClinicEditItem
            {
                Id                  = clinic.Id,
                BusinessName        = clinic.BusinessName,
                LocationName        = clinic.ShortName,
                Address             = clinic.Address,
                State               = clinic.State,
                City                = clinic.City,
                Phone               = clinic.Phone,
                WorkHours           = clinic.WorkHours,
                IsActive            = clinic.IsActive,
                Email               = clinic.Email,
                ContactPerson       = clinic.ContactPerson,
                Location            = clinic.Location,
                Comments            = clinic.Comments,
                BankAccountName     = clinic.BankAccountName,
                BankBsb             = clinic.BankBsb,
                BankAccountNumber   = clinic.BankAccountNumber,
                PaymentRatio        = clinic.PaymentRatio,
                ContractFileContent = clinic.ContractFileContent,
                ContractFileName    = string.IsNullOrEmpty(clinic.ContractFileName) ? " " : clinic.ContractFileName
            };

            return(Json(clinicItem, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult Edit(int id)
        {
            ClinicEditItem clinicItem = new ClinicEditItem();

            if (id != 0)
            {
                var clinic = _manager.GetById(id);
                if (clinic != null)
                {
                    clinicItem.Id                                      = clinic.Id;
                    clinicItem.BusinessName                            = clinic.BusinessName;
                    clinicItem.LocationName                            = clinic.ShortName;
                    clinicItem.Address                                 = clinic.Address;
                    clinicItem.State                                   = clinic.State;
                    clinicItem.City                                    = clinic.City;
                    clinicItem.Phone                                   = clinic.Phone;
                    clinicItem.WorkHours                               = clinic.WorkHours;
                    clinicItem.IsActive                                = clinic.IsActive;
                    clinicItem.Email                                   = clinic.Email;
                    clinicItem.ContactPerson                           = clinic.ContactPerson;
                    clinicItem.Location                                = clinic.Location;
                    clinicItem.Comments                                = clinic.Comments;
                    clinicItem.BankAccountName                         = clinic.BankAccountName;
                    clinicItem.BankBsb                                 = clinic.BankBsb;
                    clinicItem.BankAccountNumber                       = clinic.BankAccountNumber;
                    clinicItem.PaymentRatio                            = clinic.PaymentRatio;
                    clinicItem.ContractFileContent                     = clinic.ContractFileContent;
                    clinicItem.ABN                                     = clinic.ABN;
                    clinicItem.BusinessAddress                         = clinic.BusinessAddress;
                    clinicItem.OwnersName                              = clinic.OwnersName;
                    clinicItem.OwnersEmailAddress                      = clinic.OwnersEmailAddress;
                    clinicItem.OwnersPhoneNumber                       = clinic.OwnersPhoneNumber;
                    clinicItem.BusinessWebsiteAddress                  = clinic.BusinessWebsiteAddress;
                    clinicItem.EmailAddressForOnlineBookings           = clinic.EmailAddressForOnlineBookings;
                    clinicItem.DirectPhoneToTheLocation                = clinic.DirectPhoneToTheLocation;
                    clinicItem.StoreManagerPhoneNumber                 = clinic.StoreManagerPhoneNumber;
                    clinicItem.WebsiteLocationAddress                  = clinic.WebsiteLocationAddress;
                    clinicItem.HowToFind                               = clinic.HowToFind;
                    clinicItem.IsContractSigned                        = clinic.IsContractSigned;
                    clinicItem.IsTrained                               = clinic.IsTrained;
                    clinicItem.IsLocationsDetailsSpreadsheetsCompleted = clinic.IsLocationsDetailsSpreadsheetsCompleted;
                    clinicItem.IsTakenClientThroughWholesale           = clinic.IsTakenClientThroughWholesale;
                    clinicItem.IsClientWholesaleLoginSetuped           = clinic.IsClientWholesaleLoginSetuped;
                    clinicItem.DateOfListing                           = clinic.DateOfListing;
                    clinicItem.ContractFileName                        = string.IsNullOrEmpty(clinic.ContractFileName) ? " " : clinic.ContractFileName;
                    clinicItem.Lat                                     = clinic.Lat;
                    clinicItem.Lng                                     = clinic.Lng;
                    clinicItem.HasBookings                             = _manager.IsClinicHasBookings(id);
                    clinicItem.TreatmentCategories                     = new List <TreatmentCategoryItem>(clinic.TreatmentCategories.Select(tc => new TreatmentCategoryItem {
                        Id          = tc.Id,
                        Description = tc.Description,
                        IsActive    = tc.IsActive,
                        Name        = tc.Name,
                        PictureUrl  = tc.PictureUrl
                    }));
                    clinicItem.AllTreatmentCategories = new List <TreatmentCategoryItem>(_treatmentCategoryManager.GetAll().Select(tc => new TreatmentCategoryItem
                    {
                        Id          = tc.Id,
                        Description = tc.Description,
                        IsActive    = tc.IsActive,
                        Name        = tc.Name,
                        PictureUrl  = tc.PictureUrl
                    }));

                    clinicItem.IndicatedTreatmentCategories =
                        clinicItem.AllTreatmentCategories.Where(x => x.IsActive).Select(x =>
                                                                                        new ClinicTreatmentCategoryEditItem(
                                                                                            x.Id,
                                                                                            x.Name,
                                                                                            clinicItem.TreatmentCategories.Select(y => y.Id).Contains(x.Id))
                                                                                        ).ToList();

                    clinicItem.OpeningHours = clinic.Hours.Select(oh => new ClinicHourEditItem
                    {
                        Id               = oh.Id,
                        CloseHour        = oh.CloseHour.HasValue ? oh.CloseHour.Value.ToLocalTime() : oh.CloseHour,
                        OpenHour         = oh.OpenHour.HasValue ? oh.OpenHour.Value.ToLocalTime() : oh.OpenHour,
                        BookingOpenHour  = oh.BookingOpenHour.HasValue ? oh.BookingOpenHour.Value.ToLocalTime() : oh.BookingOpenHour,
                        BookingCloseHour = oh.BookingCloseHour.HasValue ? oh.BookingCloseHour.Value.ToLocalTime() : oh.BookingCloseHour,
                        Day              = (int)oh.Day
                    }).ToList();
                }
            }
            else
            {
                clinicItem.ContractFileName = " ";

                clinicItem.OpeningHours = new List <ClinicHourEditItem>();

                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Sunday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Monday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Tuesday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Wednesday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Thursday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Friday
                });
                clinicItem.OpeningHours.Add(new ClinicHourEditItem {
                    Day = (int)DayOfWeek.Saturday
                });

                clinicItem.AllTreatmentCategories = new List <TreatmentCategoryItem>(_treatmentCategoryManager.GetAll().Select(tc => new TreatmentCategoryItem
                {
                    Id          = tc.Id,
                    Description = tc.Description,
                    IsActive    = tc.IsActive,
                    Name        = tc.Name,
                    PictureUrl  = tc.PictureUrl
                }));

                clinicItem.IndicatedTreatmentCategories =
                    clinicItem.AllTreatmentCategories.Where(x => x.IsActive).Select(x =>
                                                                                    new ClinicTreatmentCategoryEditItem(
                                                                                        x.Id,
                                                                                        x.Name,
                                                                                        false)
                                                                                    ).ToList();
            }

            return(View("ClinicEditView", clinicItem));
        }
Esempio n. 3
0
        public ActionResult Save(ClinicEditItem clinic)
        {
            if (ModelState.IsValid)
            {
                var newClinic = new Clinic
                {
                    Id                = clinic.Id,
                    BusinessName      = clinic.BusinessName,
                    ShortName         = clinic.LocationName,
                    Address           = clinic.Address,
                    State             = clinic.State,
                    City              = clinic.City,
                    Phone             = clinic.Phone,
                    WorkHours         = clinic.WorkHours,
                    IsActive          = clinic.IsActive,
                    Email             = clinic.Email,
                    ContactPerson     = clinic.ContactPerson,
                    Location          = clinic.Location,
                    Comments          = clinic.Comments,
                    BankAccountName   = clinic.BankAccountName,
                    BankBsb           = clinic.BankBsb,
                    BankAccountNumber = clinic.BankAccountNumber,
                    PaymentRatio      = clinic.PaymentRatio,
                    Hours             = clinic.OpeningHours.Select(oh => new ClinicHours
                    {
                        Id               = oh.Id,
                        ClinicId         = clinic.Id,
                        Day              = (DayOfWeek)oh.Day,
                        OpenHour         = oh.OpenHour.HasValue ? oh.OpenHour.Value.ToUniversalTime() : oh.OpenHour,
                        CloseHour        = oh.CloseHour.HasValue ? oh.CloseHour.Value.ToUniversalTime() : oh.CloseHour,
                        BookingOpenHour  = oh.BookingOpenHour.HasValue ? oh.BookingOpenHour.Value.ToUniversalTime() : oh.BookingOpenHour,
                        BookingCloseHour = oh.BookingCloseHour.HasValue ? oh.BookingCloseHour.Value.ToUniversalTime() : oh.BookingCloseHour
                    }).ToList(),
                    HowToFind = clinic.HowToFind,
                    EmailAddressForOnlineBookings = clinic.EmailAddressForOnlineBookings,
                    OwnersEmailAddress            = clinic.OwnersEmailAddress,
                    BusinessWebsiteAddress        = clinic.BusinessWebsiteAddress,
                    ABN                                     = clinic.ABN,
                    OwnersName                              = clinic.OwnersName,
                    OwnersPhoneNumber                       = clinic.OwnersPhoneNumber,
                    WebsiteLocationAddress                  = clinic.WebsiteLocationAddress,
                    IsContractSigned                        = clinic.IsContractSigned,
                    IsTrained                               = clinic.IsTrained,
                    IsTakenClientThroughWholesale           = clinic.IsTakenClientThroughWholesale,
                    IsClientWholesaleLoginSetuped           = clinic.IsClientWholesaleLoginSetuped,
                    IsLocationsDetailsSpreadsheetsCompleted = clinic.IsLocationsDetailsSpreadsheetsCompleted,
                    DateOfListing                           = clinic.DateOfListing,
                    BusinessAddress                         = clinic.BusinessAddress,
                    StoreManagerPhoneNumber                 = clinic.StoreManagerPhoneNumber,
                    DirectPhoneToTheLocation                = clinic.DirectPhoneToTheLocation,
                    Lat                                     = clinic.Lat,
                    Lng                                     = clinic.Lng,
                    TreatmentCategories                     = _treatmentCategoryManager.GetByIds(clinic.IndicatedTreatmentCategories.Where(x => x.IsActive).Select(x => x.Id))
                };

                if (Request.Files.Count > 0)
                {
                    var file = Request.Files[0];
                    if (file != null && file.ContentLength > 0)
                    {
                        try
                        {
                            byte[] contractFile = ConvertToByte(file);
                            newClinic.ContractFileContent = contractFile;
                            newClinic.ContractFileName    = file.FileName;
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                _manager.CreateOrUpdate(newClinic);
                return(RedirectToAction("ClinicList", "Clinic"));
            }

            return(View("ClinicEditView", clinic));
        }