public async Task <ActionResult <AvailableTime> > PostAvailableTime(AvailableTime availableTime)
        {
            _context.AvailableTimes.Add(availableTime);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAvailableTime", new { id = availableTime.Id }, availableTime));
        }
        public ActionResult Create(AvailableTime availableTime)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var manager = GetManager();
                    if (manager.AvailableTimes.Where(a => a.TimeName == availableTime.TimeName).Count() != 0)
                    {
                        TempData["Alert"] = "你已经添加了这个可值班时间了!";
                        return(RedirectToAction("Index"));
                    }
                    availableTime.TimeId          = Models.Manager.FindCheckInTime(availableTime.TimeName).TimeId;
                    availableTime.AvailableTimeId = Guid.NewGuid();
                    availableTime.Manager         = GetManager();
                    db.AvailableTime.Add(availableTime);
                    db.Logs.Add(new Log(string.Format("系统:[添加]值班员[{1}]于[{0}]的可值班时间纪录。", availableTime.TimeName, manager.Name)));
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                Log.ReportException(e);
            }

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> PutAvailableTime(int id, AvailableTime availableTime)
        {
            if (id != availableTime.Id)
            {
                return(BadRequest());
            }

            _context.Entry(availableTime).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AvailableTimeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public int AddTimings(AvailableTimeDto timing)
 {
     try
     {
         int insertedId = 0;
         var stime      = new DateTime(01, 01, 01, timing.StartTime.Hour, timing.StartTime.Minute, timing.StartTime.Second);
         var etime      = new DateTime(01, 01, 01, timing.EndTime.Hour, timing.EndTime.Minute, timing.EndTime.Second);
         if (!cabODbContext.AvailableTime.Any(x => (x.OfficeCommutationId == timing.OfficeCommutationId) && (x.IsDeleted == false) && (x.StartTime == timing.StartTime) && (x.EndTime == timing.EndTime)))
         {
             var commutation = new AvailableTime
             {
                 OfficeCommutationId = timing.OfficeCommutationId,
                 StartTime           = stime,
                 EndTime             = etime,
                 IsDeleted           = false
             };
             cabODbContext.AvailableTime.Add(commutation);
             cabODbContext.SaveChanges();
             insertedId = commutation.Id;
         }
         return(insertedId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Type != global::Google.Cloud.Retail.V2.Product.Types.Type.Unspecified)
            {
                hash ^= Type.GetHashCode();
            }
            if (PrimaryProductId.Length != 0)
            {
                hash ^= PrimaryProductId.GetHashCode();
            }
            hash ^= categories_.GetHashCode();
            if (Title.Length != 0)
            {
                hash ^= Title.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            hash ^= Attributes.GetHashCode();
            hash ^= tags_.GetHashCode();
            if (priceInfo_ != null)
            {
                hash ^= PriceInfo.GetHashCode();
            }
            if (availableTime_ != null)
            {
                hash ^= AvailableTime.GetHashCode();
            }
            if (Availability != global::Google.Cloud.Retail.V2.Product.Types.Availability.Unspecified)
            {
                hash ^= Availability.GetHashCode();
            }
            if (availableQuantity_ != null)
            {
                hash ^= AvailableQuantity.GetHashCode();
            }
            if (Uri.Length != 0)
            {
                hash ^= Uri.GetHashCode();
            }
            hash ^= images_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#6
0
        //get the available areas of that restuarant and the timeslots
        public static void GetAvailablePromotions(JObject r, int slotNumber)
        {
            RestaurantPage.availableTimes.Clear();
            int capacity = 0;

            //go through each availabe timeSlot
            foreach (var day in r["AvailableDates"])
            {
                if (capacity <= slotNumber)
                {
                    Dictionary <string, string> areas = new Dictionary <string, string>();

                    foreach (var area in day["Areas"])
                    {
                        areas.Add(area["Id"].ToString(), area["Name"].ToString());
                    }

                    foreach (var time in day["AvailableTimes"])
                    {
                        if (capacity == slotNumber)
                        {
                            break;
                        }
                        else
                        {
                            StringBuilder availableAreas = new StringBuilder();
                            StringBuilder timeSlot       = new StringBuilder();

                            timeSlot.Append(time["TimeSlot"].ToString());

                            foreach (var availArea in time["AvailableAreaIds"])
                            {
                                availableAreas.Append(areas[availArea.ToString()]);
                                availableAreas.Append(" • ");
                            }
                            availableAreas.Remove(availableAreas.Length - 2, 2);

                            DateTime date = Convert.ToDateTime(day["Date"].ToString());

                            AvailableTime at = new AvailableTime
                            {
                                Date            = date.Date.ToString("dd/MM/yyyy"),
                                Time            = timeSlot.ToString().Substring(0, 5),
                                RestaurantAreas = availableAreas.ToString().Replace("\t", ""),
                                StringDate      = date.Day + " " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month) + " " + date.Year
                            };

                            GetValidPromotions(at);
                            RestaurantPage.availableTimes.Add(at);

                            capacity += 1;
                        }
                    }
                }
            }
        }
示例#7
0
        //Return the promotions for that restuarant
        //Return the promotions for that restuarant
        public static AvailableTime GetValidPromotions(AvailableTime current)
        {
            StringBuilder currentTime   = new StringBuilder();
            StringBuilder allPromotions = new StringBuilder();

            IFormatProvider provider = CultureInfo.InvariantCulture;

            currentTime.Append(current.Date);
            currentTime.Append(" ");
            currentTime.Append(current.Time);
            currentTime.Append(":00");

            DateTime dateofBooking = DateTime.ParseExact(currentTime.ToString(), "dd/MM/yyyy HH:mm:ss", provider);

            foreach (Promotion p in RestaurantPage.promotions)
            {
                if (!string.IsNullOrEmpty(p.StartDate) && !string.IsNullOrEmpty(p.StartTime) && !string.IsNullOrEmpty(p.EndDate) && !string.IsNullOrEmpty(p.EndTime))
                {
                    StringBuilder start = new StringBuilder();
                    StringBuilder end   = new StringBuilder();

                    start.Append(p.StartDate);
                    start.Append(" ");
                    start.Append(p.StartTime);

                    end.Append(p.EndDate);
                    end.Append(" ");
                    end.Append(p.EndTime);

                    DateTime startPromo = DateTime.ParseExact(start.ToString(), "dd/MM/yyyy HH:mm:ss", provider);
                    DateTime endPromo   = DateTime.ParseExact(end.ToString(), "dd/MM/yyyy HH:mm:ss", provider);

                    int res1 = DateTime.Compare(dateofBooking, startPromo);  //Should return 1 or 0 - as DateofBooking should be >= startPromo
                    int res2 = DateTime.Compare(dateofBooking, endPromo);    //Should return -1 or 0 - as DateofBooking should be =< end Promo

                    if (res1 >= 0 && res2 <= 0)
                    {
                        allPromotions.Append(p.Name + " • " + p.Description + "\n");
                    }
                }
            }

            if (allPromotions.Length > 0)
            {
                current.Promotions = allPromotions.ToString();
            }
            else
            {
                current.Promotions = "No Promotions Available";
            }

            return(current);
        }
        // GET: AvailableTimes/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AvailableTime availableTime = db.AvailableTime.Find(id);

            if (availableTime == null)
            {
                return(HttpNotFound());
            }
            return(View(availableTime));
        }
 public ActionResult Delete(Guid id)
 {
     try
     {
         AvailableTime availableTime = db.AvailableTime.Find(id);
         db.AvailableTime.Remove(availableTime);
         db.Logs.Add(new Log(string.Format("系统:[移除]值班员[{1}]于[{0}]的可值班时间纪录。", availableTime.TimeName, GetManager().Name)));
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Log.ReportException(e);
     }
     return(RedirectToAction("Index"));
 }
示例#10
0
        public IActionResult SignUp(AvailableTime timeslot)
        {
            if (ModelState.IsValid)
            {
                ViewBag.Timeslots = timeslot;
                _db.Times.Add(timeslot);
                _db.SaveChanges();

                return(View("Form"));
            }

            else
            {
                return(View());
            }
        }
示例#11
0
 public ActionResult Edit(AvailableTime availableTime)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(availableTime).State = EntityState.Modified;
             db.Logs.Add(new Log(string.Format("系统:[修改]值班员[{1}]于[{0}]的可值班时间纪录。", availableTime.TimeName, GetManager().Name)));
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception e)
     {
         Log.ReportException(e);
     }
     return(RedirectToAction("Index"));
 }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as PractitionerRole;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (ActiveElement != null)
            {
                dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy();
            }
            if (Period != null)
            {
                dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
            }
            if (Practitioner != null)
            {
                dest.Practitioner = (Hl7.Fhir.Model.ResourceReference)Practitioner.DeepCopy();
            }
            if (Organization != null)
            {
                dest.Organization = (Hl7.Fhir.Model.ResourceReference)Organization.DeepCopy();
            }
            if (Code != null)
            {
                dest.Code = new List <Hl7.Fhir.Model.CodeableConcept>(Code.DeepCopy());
            }
            if (Specialty != null)
            {
                dest.Specialty = new List <Hl7.Fhir.Model.CodeableConcept>(Specialty.DeepCopy());
            }
            if (Location != null)
            {
                dest.Location = new List <Hl7.Fhir.Model.ResourceReference>(Location.DeepCopy());
            }
            if (HealthcareService != null)
            {
                dest.HealthcareService = new List <Hl7.Fhir.Model.ResourceReference>(HealthcareService.DeepCopy());
            }
            if (Telecom != null)
            {
                dest.Telecom = new List <Hl7.Fhir.Model.ContactPoint>(Telecom.DeepCopy());
            }
            if (AvailableTime != null)
            {
                dest.AvailableTime = new List <Hl7.Fhir.Model.PractitionerRole.AvailableTimeComponent>(AvailableTime.DeepCopy());
            }
            if (NotAvailable != null)
            {
                dest.NotAvailable = new List <Hl7.Fhir.Model.PractitionerRole.NotAvailableComponent>(NotAvailable.DeepCopy());
            }
            if (AvailabilityExceptionsElement != null)
            {
                dest.AvailabilityExceptionsElement = (Hl7.Fhir.Model.FhirString)AvailabilityExceptionsElement.DeepCopy();
            }
            if (Endpoint != null)
            {
                dest.Endpoint = new List <Hl7.Fhir.Model.ResourceReference>(Endpoint.DeepCopy());
            }
            return(dest);
        }
示例#13
0
        public static void Initialize(AdminContext context)
        {
            context.Database.EnsureCreated();

            // Look for existing volunteers
            if (context.Volunteers.Any())
            {
                return;
            }

            var volunteers = new Volunteer[]
            {
                new Volunteer {
                    FirstName = "James", LastName = "Jameson", Username = "******", Password = "******", HomePhone = "1111111111", CellPhone = "2222222222", WorkPhone = "3333333333", Address = "101 Address Road", Email = "*****@*****.**", Education = "Bachelors", EmergencyName = "Tom", EmergencyHomePhone = "1111111111", EmergencyWorkPhone = "2222222222", EmergencyEmail = "*****@*****.**", EmergencyAddress = "123 Road Lane", DLCopyOnFile = true, SSCopyOnFile = true, Approved = true
                },
                new Volunteer {
                    FirstName = "John", LastName = "Johnson", Username = "******", Password = "******", HomePhone = "1111111111", CellPhone = "2222222222", WorkPhone = "3333333333", Address = "101 Address Road", Email = "*****@*****.**", Education = "Masters", EmergencyName = "James", EmergencyHomePhone = "1111111111", EmergencyWorkPhone = "2222222222", EmergencyEmail = "*****@*****.**", EmergencyAddress = "123 Road Lane", DLCopyOnFile = true, SSCopyOnFile = true, Approved = false
                }
            };

            foreach (Volunteer v in volunteers)
            {
                context.Volunteers.Add(v);
            }
            context.SaveChanges();

            var availableTimes = new AvailableTime[]
            {
                new AvailableTime {
                    Time = DateTime.Parse("2:00PM")
                },
                new AvailableTime {
                    Time = DateTime.Parse("6:00AM")
                },
                new AvailableTime {
                    Time = DateTime.Parse("10:00AM")
                }
            };

            foreach (AvailableTime a in availableTimes)
            {
                context.AvailableTimes.Add(a);
            }
            context.SaveChanges();

            var centers = new Center[]
            {
                new Center {
                    CenterName = "North"
                },
                new Center {
                    CenterName = "West"
                },
                new Center {
                    CenterName = "Southside"
                }
            };

            foreach (Center c in centers)
            {
                context.Centers.Add(c);
            }
            context.SaveChanges();

            var licenses = new License[]
            {
                new License {
                    LicenseName = "ABC"
                },
                new License {
                    LicenseName = "DEF"
                },
                new License {
                    LicenseName = "GHI"
                }
            };

            foreach (License l in licenses)
            {
                context.Licenses.Add(l);
            }
            context.SaveChanges();

            var skills = new Skill[]
            {
                new Skill {
                    SkillName = "Leadership"
                },
                new Skill {
                    SkillName = "Organization"
                },
                new Skill {
                    SkillName = "Positivity"
                }
            };

            foreach (Skill s in skills)
            {
                context.Skills.Add(s);
            }
            context.SaveChanges();
        }
示例#14
0
 public void MergeFrom(Product other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Name.Length != 0)
     {
         Name = other.Name;
     }
     if (other.Id.Length != 0)
     {
         Id = other.Id;
     }
     if (other.Type != global::Google.Cloud.Retail.V2.Product.Types.Type.Unspecified)
     {
         Type = other.Type;
     }
     if (other.PrimaryProductId.Length != 0)
     {
         PrimaryProductId = other.PrimaryProductId;
     }
     categories_.Add(other.categories_);
     if (other.Title.Length != 0)
     {
         Title = other.Title;
     }
     if (other.Description.Length != 0)
     {
         Description = other.Description;
     }
     attributes_.Add(other.attributes_);
     tags_.Add(other.tags_);
     if (other.priceInfo_ != null)
     {
         if (priceInfo_ == null)
         {
             PriceInfo = new global::Google.Cloud.Retail.V2.PriceInfo();
         }
         PriceInfo.MergeFrom(other.PriceInfo);
     }
     if (other.availableTime_ != null)
     {
         if (availableTime_ == null)
         {
             AvailableTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
         }
         AvailableTime.MergeFrom(other.AvailableTime);
     }
     if (other.Availability != global::Google.Cloud.Retail.V2.Product.Types.Availability.Unspecified)
     {
         Availability = other.Availability;
     }
     if (other.availableQuantity_ != null)
     {
         if (availableQuantity_ == null || other.AvailableQuantity != 0)
         {
             AvailableQuantity = other.AvailableQuantity;
         }
     }
     if (other.Uri.Length != 0)
     {
         Uri = other.Uri;
     }
     images_.Add(other.images_);
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }