public bool SchedualAppointment(Appointment appointment)
        {
            bool succeded;

            switch (appointment.Company.Type)
            {
                case CompanyType.Banks:
                    {
                        succeded = PostAppointment("Bank", appointment);
                        break;
                    }
                case CompanyType.MedicalClinic:
                    {
                        succeded = PostAppointment("MedicalClinic",appointment);
                        break;
                    }
                case CompanyType.PostOffice:
                    {
                        succeded = PostAppointment("PostOffice",appointment);
                        break;
                    }
                default:
                    throw new ArgumentOutOfRangeException(nameof(appointment.Company.Type), appointment.Company.Type, null);
            }

            return succeded;
        }
Example #2
0
 public PathItemHandler(Appointment app)
 {
     StartTime = app.Time;
     EndTime = app.Time.AddHours(1);
     Type = PathItemType.Appointment;
     Id = app.Company.Id;
 }
Example #3
0
 public Appointment[] Get(string customerId = "")
 {
     HttpResponseMessage response = _client.GetAsync("api/Appointment").Result;
     Appointment obj = JsonConvert.DeserializeObject<Appointment>(response.Content.ReadAsStringAsync().Result);
     Appointment[] data = new Appointment[1];
     data[0] = obj;
     return data;
 }
        private bool PostAppointment(string controllerName,Appointment appointment)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost:61820/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response =  client.PostAsJsonAsync("api/" + controllerName, appointment.Id).Result;
            return response.IsSuccessStatusCode;
        }
Example #5
0
        public List<Appointment> ConvertToAppointments()
        {
            List<Appointment> appointments = new List<Appointment>();

            foreach(DbAppointment dbAppointment in this.freeAppointments)
            {
                Appointment app = new Appointment();
                app.Company = this.Company;
                app.Remark = dbAppointment.Remark;
                app.Time = dbAppointment.StartTime;
                appointments.Add(app);
            }

            return appointments;
        }
Example #6
0
        public string Post()
        {
            var company = new Company()
            {
                Id = ObjectId.GenerateNewId().ToString(),
                //Location = new Location() {X = 32.5669, Y = 36.5589},
                Type = CompanyType.Banks,
                UrlForApi = "this ia the best uri in the world hai tov baolam!!!!!",
                SubType = CompanySubType.BankDiscount
            };

            var gizmo = new Appointment()
            {
                Id = ObjectId.GenerateNewId().ToString(),
                Remark = "hhh",
                //CompanyId = "567548f8d9f4b33b10815214",
                Time = DateTime.Now
            };

            var response1 = _client.PostAsJsonAsync("http://localhost:60799/api/Company", company).Result;
               var response = _client.PostAsJsonAsync("http://localhost:60799/api/Appointment", gizmo).Result;
            return response.Content.ToString();
        }
Example #7
0
 public void AddAppointment(Appointment appointment)
 {
     Path.Appointments.Add(appointment);
 }
Example #8
0
 public bool IsAppointmentAddable(Appointment appointment, Dictionary<Tuple<string, string>, int> deltaTimeMatrix)
 {
     List<PathItemHandler> items = new List<PathItemHandler>();
     Path.Appointments.ForEach(a => items.Add(new PathItemHandler(a)));
     for (int i = 0; i < Path.Constraints.Count; i++)
     {
         items.Add(new PathItemHandler(Path.Constraints[i], i));
     }
     //Path.Constraints.ForEach(c => items.Add(new PathItemHandler(c)));
     items = items.OrderBy(i => i.StartTime).ToList<PathItemHandler>();
     PathItemHandler lastItem = null;
     foreach (var item in items)
     {
         if (item.StartTime > appointment.Time)
         {
             if (GetDeadTime(new PathItemHandler(appointment), item, deltaTimeMatrix) >= new TimeSpan())
             {
                 if (lastItem == null || GetDeadTime(lastItem, new PathItemHandler(appointment), deltaTimeMatrix) > new TimeSpan())
                     return true;
             }
             return false;
         }
         else if (item.EndTime > appointment.Time)
             return false;
         lastItem = item;
     }
     return true;
 }