public MonthlyModel(Monthly monthly) { this.ID = monthly.ID; this.Month = monthly.Month; this.Cost = monthly.Cost; this.Remark = monthly.Remark; }
public HttpResponseMessage CreateMonthly(Monthly Monthly) { var user = MemberHelper.GetUserProfile(db); if (!CheckCreationAuth(user)) { return(new HttpResponseMessage(HttpStatusCode.Forbidden)); } try { if (ModelState.IsValid) { Monthly.FreelancerID = user.UserID; ProcessRefundCreation(Monthly.Refund, user); db.Monthlies.Add(Monthly); db.SaveChanges(); SendMonthlyNotification(user, Monthly); return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } catch (Exception e) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public MonthlyModel(Monthly monthly) { this.ID = monthly.ID; this.Month = monthly.Month; this.Cost = monthly.Cost; this.Remark = monthly.Remark; }
public ScheduleDefinition() { StartDate = Controller.ScheduleController.GetToday(); Type = ScheduleType.Weekly; DaylyPeriod = new Dayly(); WeeklyPeriod = new Weekly(); MonthlyPeriod = new Monthly(); YearlyPeriod = new Yearly(); }
/// <summary> /// Creates the range for months with the default frequncy rate /// </summary> /// <param name="months">period count</param> /// <param name="frequncy">frequency rate</param> /// <returns>configured range object</returns> public static History Months(HowManyMonths months, Monthly frequncy) { var ft = frequncy switch { Monthly.ByDay => Models.FrequencyType.Daily, Monthly.ByWeek => Models.FrequencyType.Weekly, _ => throw new NotImplementedException(), }; return(Create(Models.PeriodType.Month, (ushort?)months, ft, null)); }
public Monthly ToMonthly() { Monthly monthly = new Monthly() { ID = this.ID, Month = this.Month, Cost = this.Cost, Remark = this.Remark }; return monthly; }
public Monthly ToMonthly() { Monthly monthly = new Monthly() { ID = this.ID, Month = this.Month, Cost = this.Cost, Remark = this.Remark }; return monthly; }
public PortalViewModel(DateTime today, int numberOfDays, int numberOfMonths, List <Duty> duties) { int maxDays = numberOfDays; int maxMonths = numberOfMonths; var currentDate = today; int daysCount = 0; int monthCount = 0; int weekNumber = 0; do { var monthlySchedule = Monthly.FirstOrDefault(m => m.Month == currentDate.Month && m.Year == currentDate.Year); if (monthlySchedule == null) { monthlySchedule = new MonthSchedule() { Month = currentDate.Month, MonthName = currentDate.ToString("MMMM"), Year = currentDate.Year }; monthCount += 1; if (monthCount > maxMonths) { break; } Monthly.Add(monthlySchedule); weekNumber = 1; } var weeklySchedule = monthlySchedule.Weekly.FirstOrDefault(m => m.WeekNumber == weekNumber); if (weeklySchedule == null) { weeklySchedule = new WeekSchedule() { WeekNumber = weekNumber, DayOfWeek = (int)currentDate.DayOfWeek }; monthlySchedule.Weekly.Add(weeklySchedule); } var duty = duties.FirstOrDefault(d => d.Date.Date == currentDate.Date); if (duty != null) { weeklySchedule.Daily.Add(new Duty() { Date = currentDate, vacationPlan = duty.vacationPlan, isDayOff = duty.isDayOff, Details = duty?.Details }); } daysCount++; currentDate = currentDate.AddDays(1); if (currentDate.DayOfWeek == DayOfWeek.Sunday) { weekNumber++; } }while (daysCount < maxDays); }
private void SendMonthlyNotification(UserProfile user, Monthly Monthly) { var mailer = new UserMailer(); foreach (var manager in user.RefundProfile.Freelancer.Managers) { mailer.SendMonthlyNotification( manager.RefundProfile.User.ContactInfo.Email, Url.Action("MonthlyDetail", "Manager", new { @id = Monthly.MonthlyID }), user.PersonalInfo.ArtisticName ?? user.PersonalInfo.Name, Monthly.Month.DisplayName(), Server.MapPath("~/Content/images/logo-wella.png") ).Send(); } }
public void TestOps() { Monthly plan = 201801; Assert.AreEqual(plan + 12, 201901); Assert.AreEqual(plan - 13, 201612); Assert.AreEqual(plan - (Monthly)201701, 12); Assert.AreEqual(plan - (new DateTime(2017, 12, 12)), 1); Assert.AreEqual(--plan, 201712); Assert.AreEqual(++plan, 201801); Assert.IsTrue(plan == Monthly.FromDot(201801)); Assert.IsTrue(plan != Monthly.FromDot(201802)); Assert.IsTrue(plan >= Monthly.FromDot(201801)); Assert.IsTrue(plan < Monthly.FromDot(201803)); }
public CreateMonthlyVM(Freelancer freelancer, string submitText, [AspMvcAction] string submitAction, [AspMvcController] string submitController = "Freelancer", [AspMvcAction] string successAction = "Monthlies", [AspMvcController] string successController = "Freelancer") : base(submitText, submitAction, submitController, successAction, successController) { var now = DateTime.Now; Monthly = new Monthly { Month = (Month)now.Month, Year = now.Year, Refund = new Refund { RefundItems = new Collection <RefundItem> { new RefundItem { Activity = "Reembolso Mensal", Category = RefundItemCategory.SALARY, Files = new Collection <File>(), Value = freelancer.Remuneration } } } }; }
public void TestOvr() { Monthly plan = 201801; var tar = Monthly.FromString("2018.01"); //哈希码(相同dot具有相同的哈希码) Assert.AreEqual(plan.GetHashCode(), tar.GetHashCode()); tar++; Assert.AreNotEqual(plan.GetHashCode(), tar.GetHashCode()); //格式化 Assert.AreEqual(plan.ToString(), "2018/01"); Assert.AreEqual(plan.ToString("yy/mm"), "18/01"); Assert.AreEqual(Monthly.FromDot(501).ToString("yy/mm"), "05/01"); Assert.AreEqual(plan.ToString("YYYY年m月"), "2018年1月"); Assert.AreEqual(plan.ToString("公元YyYy年mM月,哈哈..."), "公元2018年01月,哈哈..."); //比较相等 Assert.IsTrue(plan.Equals(Monthly.FromDot(201801))); Assert.IsTrue(plan.Equals(new DateTime(2018, 1, 1))); Assert.IsTrue(plan.Equals((object)Monthly.FromDot(201801))); Assert.IsFalse(plan.Equals(Monthly.FromDot(201901))); }
public ActionResult Monthly() { var expenseList = DB.Expenses.ToList(); // Group transactions by month var groupMonths = expenseList.GroupBy(x => x.TransactionMonth) .Select(group => new { Expens = group.Key, expenseList = group.ToList() }) .ToList(); var itemList = new List <List <Expens> >(); foreach (var transaction in groupMonths) { itemList.Add(transaction.expenseList); } var monthList = new List <Monthly>(); foreach (var list in itemList) { var month = new Monthly(); foreach (var item in list) { month.TotalSpent += item.Amount; month.TransactionMonth = item.TransactionMonth; } month.NumOfTransactions = list.Count; month.AverageSpent = Decimal.Round((month.TotalSpent / month.NumOfTransactions), 2); monthList.Add(month); } ViewBag.Months = monthList; return(View(expenseList)); }
public void TestProps() { var tar = DateTime.Now; Monthly plan = Monthly.FromDate(tar); Assert.AreEqual(Monthly.Current, new Monthly(tar.Year, tar.Month)); Assert.AreEqual(plan.Year, tar.Year); Assert.AreEqual(plan.Month, tar.Month); Assert.AreEqual(plan.Dot, tar.Year * 100 + tar.Month); Assert.AreEqual(plan.Tickes, tar.Year * 12 + tar.Month); Assert.AreEqual(plan.First.ToDot(), tar.Year * 100 + 1); Assert.AreEqual(plan.Last.ToDot(), tar.Year * 100 + 12); Assert.AreEqual(plan.First.Previous.ToDot(), tar.AddYears(-1).Year * 100 + 12); Assert.AreEqual(plan.Last.Next.ToDot(), tar.AddYears(1).Year * 100 + 1); Assert.AreEqual(plan.Quarter, GetQuarter(tar.Month)); Assert.AreEqual(Monthly.MinValue, new Monthly(0, 1)); Assert.AreEqual(Monthly.MaxValue, new Monthly(9999, 12)); }
public object GetList(int guests) { var sittings = _db.Sittings.Include(s => s.SittingType).Include(r => r.Reservations); //generate list of times that are under the guest limit defined in reservations var availableSittings = new List <Sitting>(); foreach (var sitting in sittings) { if (sitting.Reservations.Count == 0 && guests <= sitting.Capacity) { availableSittings.Add(sitting); } else { int[] slots = sitting.GetSlots(); for (int i = 0; i < slots.Length; i++) { if ((guests + slots[i]) <= sitting.Capacity) { availableSittings.Add(sitting); break; } } } } foreach (var sitting in sittings) { if (!availableSittings.Contains(sitting)) { sitting.Open = false; availableSittings.Add(sitting); } } //generate list of events for api var eventList = new List <Monthly>(); foreach (var item in availableSittings) { DateTime st = item.Start; DateTime et = item.End; string colour = "#b2b5c6"; string url = ""; string name = " (Reservation Unavailable)"; if (item.Open) { colour = "#f87698"; url = "/Reservation/Form?id=" + item.Id + "&guests=" + guests; name = ""; } var Event = new Monthly { id = item.Id, name = item.SittingType.Description + name, startdate = st.ToString("yyyy-MM-dd"), enddate = et.ToString("yyyy-MM-dd"), starttime = st.ToString("h:mm"), endtime = et.ToString("h:mm"), color = colour, url = url, }; eventList.Add(Event); } var root = new RootObject(eventList); return(root); }
public MvcMailMessage MonthlyResponseNotification(string email, [AspMvcController] string controller, string sender, Monthly monthly, RefundItemUpdate[] updates, string logoPath) { ViewBag.Controller = controller; ViewBag.Sender = sender; ViewBag.Monthly = monthly; ViewBag.Updates = updates; var message = Populate(x => { x.Subject = string.Format("Resposta de {0} na requisição do mês de \"{1}\"", sender, monthly.Month); x.From = new MailAddress("*****@*****.**", "Equipe Wella Educação"); x.ViewName = "MonthlyResponseNotification"; x.To.Add(email); }); var resources = new Dictionary <string, string>(); resources["logo"] = logoPath; PopulateBody(message, "MonthlyResponseNotification", resources); return(message); }
static async Task Main(string[] args) { //await Monthly.Interval(1, 10); await Monthly.Interval(1, 5, DayOfWeek.Monday); }
public void TestMethods() { Monthly plan = 201801; var tar = new DateTime(2018, 1, 1); var tip = false; //Dot Assert.AreEqual(new Monthly(0, 11), 11); Assert.AreEqual(new Monthly(1, 1), 101); Assert.AreEqual(new Monthly(100, 12), 10012); Assert.AreEqual(new Monthly(2018, 12), 201812); //Tickes Assert.AreEqual(((Monthly)101).Tickes, 13); Assert.AreEqual(((Monthly)201811).Tickes, 2018 * 12 + 11); //加月 Assert.AreEqual(plan.AddMonths(-1), 201712); Assert.AreEqual(plan.AddMonths(-23), 201602); Assert.AreEqual(plan.AddMonths(22), 201911); //加月(随机) for (int i = 0; i < 100; i++) { var rd = new Random(Guid.NewGuid().GetHashCode()).Next(100); Assert.AreEqual(plan.AddMonths(rd), Monthly.FromDate(tar.AddMonths(rd))); Assert.AreEqual(plan.AddMonths(rd).Dot, tar.AddMonths(rd).Year * 100 + tar.AddMonths(rd).Month); } //加年 Assert.IsTrue(plan.AddYears(6) == 202401); Assert.IsTrue(plan.AddYears(-18) == 200001); //加年(异常) try { var m = Monthly.Current.AddYears(-3000); } catch (Exception e) { tip |= e.Message.Contains("beteen 1 and 120000"); } Assert.IsTrue(tip); //月份差 Assert.AreEqual(plan.SpanMonths(201711), 2); Assert.AreEqual(plan.SpanMonths(201902), -13); //比较大小 Assert.AreEqual(plan.CompareTo(201801), 0); Assert.AreEqual(plan.CompareTo(201701), 1); Assert.AreEqual(plan.CompareTo(202001), -1); //构造 Assert.AreEqual(Monthly.FromDot(3), 3); Assert.AreEqual(Monthly.FromTickes(13), 101); Assert.AreEqual(Monthly.FromDate(new DateTime(2018, 12, 12)), 201812); Assert.AreEqual(Monthly.FromString("2018/01"), 201801); Assert.AreEqual(Monthly.FromString("2018年01月"), 201801); Assert.AreEqual(Monthly.FromString("2018@01/01"), 201801); Assert.AreEqual(Monthly.FromString(new DateTime(2018, 1, 1).ToString("yyyy-MM")), 201801); Assert.AreEqual(Monthly.FromString("3"), 3); //月份轴 var axis = Monthly.Axis(201711, 201901); Assert.IsTrue(axis.Count == 15); Assert.AreEqual(axis[0], 201711); Assert.AreEqual(axis[3], 201802); Assert.AreEqual(axis[14], 201901); axis = Monthly.Axis(201812, 201712); Assert.IsTrue(axis.Count == 13); Assert.AreEqual(axis[0], 201812); Assert.AreEqual(axis[12], 201712); //异常 tip = false; try { Monthly m = 201800; } catch (Exception e) { tip |= e.Message.Contains("correct dot format"); } //dot format Assert.IsTrue(tip); tip = false; try { Monthly m = Monthly.FromDot(13); } catch (Exception e) { tip |= e.Message.Contains("correct dot format"); } //13月 Assert.IsTrue(tip); tip = false; try { Monthly m = Monthly.FromTickes(999999); } catch (Exception e) { tip |= e.Message.Contains("must beteen 1 and 120000"); } //越界 Assert.IsTrue(tip); tip = false; try { Monthly m = Monthly.FromString(null); } catch (Exception e) { tip |= e.Message.Contains("null or empty"); } //IsNullOrEmpty Assert.IsTrue(tip); tip = false; try { Monthly m = Monthly.FromString("abc"); } catch (Exception e) { tip |= e.Message.Contains("parameters"); } //格式错误 Assert.IsTrue(tip); tip = false; try { Monthly m = Monthly.FromString("88"); } catch (Exception e) { tip |= e.Message.Contains("must beteen"); } //越界 Assert.IsTrue(tip); }
public string SearchQuery() { return(Today.ToString() + "/" + Weekly.ToString() + "/" + Monthly.ToString() + "/" + Annually.ToString() + "/" + UsedTotal.ToString()); }