Example #1
0
        public void Setup()
        {
            _carsRepo = new Mock <IRepository <string, Car> >();

            _diaryRepo     = new Mock <IRepository <string, DiaryItem> >();
            _unitUnderTest = new DiaryService(_diaryRepo.Object, _carsRepo.Object);
        }
Example #2
0
    private async Task <string> GetMJML(List <EntryModel> memories, string userId, string babyName)
    {
        var importResultModel = new ImportResultModel
        {
            Entries = memories
        };

        var model = DiaryService.GetDays(importResultModel);

        model.BabyName           = babyName;
        model.MemoriesBadgeCount = memories.Count;
        model.ShowMemoriesLink   = true;
        model.BaseUrl            = _configuration["BASE_URL"];
        model.Profile            = new Profile
        {
            UserId = userId
        };

        model.Entries = model.Entries
                        .OrderByDescending(entry => entry.TimeUTC.Year)
                        .OrderBy(entry => entry.TimeUTC.TimeOfDay);

        var mjml = await RazorTemplateEngine.RenderAsync("/Views/Emails/MemoriesEmail.cshtml", model);

        return(mjml);
    }
Example #3
0
        async Task WriteDiaryAsync()
        {
            if (!IsAuthenticated)
            {
                return;
            }

            if (DiaryInfo == null)
            {
                return;
            }

            DiaryContent content;

            if (DiaryInfo.IsSecret)
            {
                content = await DiaryService.WriteDiaryAsync(User, DiaryInfo, Date, Content, UserData.Password);
            }
            else
            {
                content = await DiaryService.WriteDiaryAsync(User, DiaryInfo, Date, Content);
            }

            if (content != null)
            {
                Navi.NavigateTo(DiaryUrl.DiaryContent(DiaryInfo.DiaryName, Date));
            }
        }
Example #4
0
        private async Task EditDiary()
        {
            if (!IsAuthenticated)
            {
                return;
            }

            if (DiaryInfo == null)
            {
                return;
            }

            List <DiaryContent> content;

            if (DiaryInfo.IsSecret)
            {
                content = await DiaryService.UpdateDiaryAsync(User, DiaryInfo, View.DiaryContents, UserData.Password);
            }
            else
            {
                content = await DiaryService.UpdateDiaryAsync(User, DiaryInfo, View.DiaryContents);
            }

            if (content?.Any() ?? false)
            {
                Navi.NavigateTo(DiaryUrl.DiaryContent(DiaryInfo.DiaryName, content.First().Date));
            }
            else
            {
                Navi.NavigateTo(DiaryUrl.Home(DiaryInfo.DiaryName));
            }
        }
Example #5
0
    public async Task <IActionResult> Diary(string babyName, string inputDate)
    {
        var date = DateTime.Now;

        if (!string.IsNullOrEmpty(inputDate))
        {
            date = DateTime.Parse(inputDate);
        }

        var entries = await _sqLiteService.GetEntriesFromDb(date, User, babyName);

        var importResultModel = new ImportResultModel
        {
            Entries = entries
        };
        var model = DiaryService.GetDays(importResultModel);

        model.Date         = date.ToString("yyyy-MM-dd");
        model.DateNext     = date.AddDays(1).ToString("yyyy-MM-dd");
        model.DatePrevious = date.AddDays(-1).ToString("yyyy-MM-dd");
        model.BabyName     = babyName;
        model.Profile      = await _accountService.GetProfile(User);

        var memories = await _sqLiteService.GetMemoriesFromDb(DateTime.Now, User, babyName);

        model.MemoriesBadgeCount = memories.Count;
        model.ShowMemoriesLink   = true;

        ViewData["LastEntry"] = await _sqLiteService.GetLastEntryDateTime(User, babyName);

        return(View("Diary", model));
    }
Example #6
0
        protected override async Task OnPageInitializedAsync()
        {
            if (!IsAuthenticated)
            {
                Navi.NavigateTo("/login");
                return;
            }

            var list = await DiaryService.GetWritableDiaryInfoAsync(User);

            DiaryInfo = list.FirstOrDefault(x => x.DiaryName == DiaryName);

            if (DiaryInfo == null)
            {
                Navi.NavigateTo(DiaryUrl.Home(DiaryName));
            }

            if (DiaryInfo.IsSecret && string.IsNullOrWhiteSpace(UserData.Password))
            {
                Navi.NavigateTo(DiaryUrl.SetPassword());
                return;
            }

            LastDiary = await DiaryService.GetLastDiaryViewAsync(User, DiaryInfo);

            Date = DateTime.Today;
        }
        private async Task <DiaryInfo> GetDiaryInfo(string diaryName)
        {
            if (string.IsNullOrWhiteSpace(diaryName))
            {
                return(null);
            }

            return(await DiaryService.GetDiaryInfoAsync(User, diaryName));
        }
        public VulcanAccount(LoginConfig login)
        {
            RestClient.CookieContainer = new CookieContainer();
            this.Login   = login;
            UrlGenerator = new UrlGenerator(Login.Host, Login.BaseSymbol);

            LoginService = new LoginService(this);
            DiaryService = new DiaryService(this);
        }
Example #9
0
        private async Task Search(DiarySearchData searchData)
        {
            var files = await DiarySearchService.SearchAsync(DiaryInfo.DiaryName, searchData) ?? new List <DiaryFileName>();

            var contents = await files
                           .Select(async filename => await DiaryService.GetDiaryContentAsync(User, DiaryInfo, filename))
                           .WhenAll();

            DiaryContentList = contents.Where(x => x != null).ToList();
        }
Example #10
0
        public void Setup()
        {
            MapperConfiguration mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingDiary <DiaryData>());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            diaryService = new DiaryService <DiaryData>(workingWithDiaryForTest, mapper);
        }
        private async Task <DiaryInfo> GetMyDiaryInfo()
        {
            var userDiaryInfo = await DiaryService.GetUserDiaryInfoAsync(User);

            if (userDiaryInfo?.MyDiaryList?.Empty() ?? true)
            {
                return(null);
            }

            var diaryName = userDiaryInfo.MyDiaryList.First();

            return(await GetDiaryInfo(diaryName));
        }
Example #12
0
        public void TestMethod1()
        {
            DiaryService diaryService = new DiaryService(new HandleJSON());

            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("Eliad", "08:00", "12:00"), diaryService), true);
            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("", "12:00", "10:00"), diaryService), false);
            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("Eliad", "12:30", "16:00"), diaryService), false);


            Assert.AreEqual(diaryService.isAppearInEnd("12:00"), true);
            Assert.AreEqual(diaryService.isAppearInEnd("18:00"), false);

            Assert.AreEqual(diaryService.isAppearInStart("12:00"), true);
            Assert.AreEqual(diaryService.isAppearInStart("17:50"), false);
        }
Example #13
0
        public TaskReturnValue GetMatterTaskDetails(HostSecurityToken oHostSecurityToken, Guid projectId, Int32 taskId)
        {
            TaskReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.GetMatterTaskDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId, taskId);
            }
            else
            {
                returnValue         = new TaskReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #14
0
        public ReturnValue DeleteBooking(HostSecurityToken oHostSecurityToken, DeleteData deleteData)
        {
            ReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.DeleteBooking(Functions.GetLogonIdFromToken(oHostSecurityToken), deleteData);
            }
            else
            {
                returnValue         = new ReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #15
0
        public AppointmentReturnValue GetAppointmentDetails(HostSecurityToken oHostSecurityToken, Int32 appointmentId)
        {
            AppointmentReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.GetAppointmentDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), appointmentId);
            }
            else
            {
                returnValue         = new AppointmentReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #16
0
        public DiaryMemberSearchReturnValue GetDiaryMembers(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
        {
            DiaryMemberSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.GetDiaryMembers(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
            }
            else
            {
                returnValue         = new DiaryMemberSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #17
0
        public TaskReturnValue SaveTask(HostSecurityToken oHostSecurityToken, Task taskDetails)
        {
            TaskReturnValue returnValue = new TaskReturnValue();

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.SaveTask(Functions.GetLogonIdFromToken(oHostSecurityToken), taskDetails);
            }
            else
            {
                returnValue         = new TaskReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #18
0
        public CancellationCodeSearchReturnValue GetBookingCancelledCategories(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest)
        {
            CancellationCodeSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.GetBookingCancelledReasons(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest);
            }
            else
            {
                returnValue         = new CancellationCodeSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #19
0
        public AppointmentSearchReturnValue AppointmentSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
                                                              AppointmentSearchCriteria criteria)
        {
            AppointmentSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oDiaryService = new DiaryService();
                returnValue   = oDiaryService.AppointmentSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue         = new AppointmentSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
Example #20
0
    public async Task <IActionResult> Memories(string babyName)
    {
        var memories = await _sqLiteService.GetMemoriesFromDb(DateTime.Now, User, babyName);

        var importResultModel = new ImportResultModel
        {
            Entries = memories
        };

        var model = DiaryService.GetDays(importResultModel);

        model.BabyName           = babyName;
        model.MemoriesBadgeCount = memories.Count;
        model.ShowMemoriesLink   = true;
        model.Profile            = await _accountService.GetProfile(User);

        return(View("Memories", model));
    }
        public void InitializeStudents()
        {
            LoginService.Login(Login.Email, Login.Password, out var certificate, out var sendCertificate);

            var lastSymbol = Login.BaseSymbol;

            foreach (var schoolSymbol in certificate.Wresult.Symbols.Select(x => x.Trim()).Where(x => new Regex("[a-zA-Z]*").IsMatch(x)))
            {
                UrlGenerator.Symbol = schoolSymbol;
                certificate.Action  = certificate.Action.Replace(lastSymbol, schoolSymbol);
                lastSymbol          = schoolSymbol;

                try
                {
                    sendCertificate = LoginService.SendCertificate(certificate);
                }
                catch (Exception)
                {
                    continue;
                }

                if (!sendCertificate.IsValid())
                {
                    continue;
                }

                UrlGenerator.SchoolId = sendCertificate.StudentSchools[0].Split('/')[4];

                var diares = DiaryService.GetDiares();
                if (diares.Success)
                {
                    foreach (var diary in diares.Data)
                    {
                        if (!Students.Any(x => x.StudentId == diary.StudentId))
                        {
                            Students.Add(new Student.Student(diary.StudentId, UrlGenerator.SchoolId, UrlGenerator.Symbol, diary.StudentName, diary.StudentLastName, diary));
                        }
                    }
                }
            }
        }
Example #22
0
        protected override async Task OnPageInitializedAsync()
        {
            if (!IsAuthenticated)
            {
                Navi.NavigateTo("/login");
                return;
            }

            DiaryInfo = await DiaryService.GetDiaryInfoAsync(User, DiaryName);

            var list = await DiaryService.GetDiaryFileAllAsync(User, DiaryInfo);

            if (list?.Empty() ?? true)
            {
                searchData = null;
                return;
            }

            searchData           = new DiarySearchData();
            searchData.BeginDate = list.First().Date;
            searchData.EndDate   = list.Last().Date;
        }
Example #23
0
        public UserResponse(User user)
        {
            Id      = user.Id;
            Name    = user.Name;
            Surname = user.Surname;
            City    = user.City;
            if (user.UserDetails != null)
            {
                //UserDetails = new UserDetailsResponse(user.UserDetails);
                UserService userService = new UserService();
                UserDetails = userService.ReadUserDetailsById(user.UserDetails.Id);
            }

            if (user.Diaries != null)
            {
                Diaries = new List <DiaryResponse>();
                DiaryService diaryService = new DiaryService();
                foreach (var diary in user.Diaries)
                {
                    Diaries.Add(diaryService.GetDiary(diary.Id));
                }
            }
        }
Example #24
0
        private async Task InitDiary()
        {
            DiaryInfo = null;
            View      = null;

            if (!string.IsNullOrWhiteSpace(DiaryName))
            {
                DiaryInfo = await DiaryService.GetDiaryInfoAsync(User, DiaryName);
            }
            else
            {
                var userDiaryInfo = await DiaryService.GetUserDiaryInfoAsync(User);

                if (userDiaryInfo.MyDiaryList.Empty())
                {
                    return;
                }

                var diaryName = userDiaryInfo.MyDiaryList.First();
                DiaryInfo = await DiaryService.GetDiaryInfoAsync(User, diaryName);
            }

            if (DiaryInfo == null)
            {
                return;
            }

            if (DiaryInfo.IsSecret && string.IsNullOrWhiteSpace(UserData.Password))
            {
                Navi.NavigateTo(DiaryUrl.SetPassword());
                return;
            }
            //WritableDiary = await DiaryService.GetWritableDiaryInfoAsync(User);
            //ViewableDiary = await DiaryService.GetViewableDiaryInfoAsync(User);

            if (HasDiaryInfo)
            {
                if (string.IsNullOrWhiteSpace(Date))
                {
                    View = await DiaryService.GetLastDiaryViewAsync(User, DiaryInfo);
                }
                else if (Date.TryToDate(out var parsedDate))
                {
                    View = await DiaryService.GetDiaryViewAsync(User, DiaryInfo, parsedDate);
                }

                if (DiaryInfo.IsSecret && HasDiaryContent)
                {
                    foreach (var content in View?.DiaryContents)
                    {
                        try
                        {
                            content.Text = content.Text.Decrypt(UserData.Password);
                        }
                        catch
                        {
                            content.Text = "임호화된 일기를 해석하지 못했습니다. 비밀번호를 다시 확인해주세요.";
                        }
                    }
                }
            }
        }
Example #25
0
 public PublishModel()
 {
     _diaryService = new DiaryService();
 }
Example #26
0
 public DiaryController()
 {
     this._diaryService = new DiaryService();
 }
Example #27
0
 public DiaryServiceTests()
 {
     _target = new DiaryService(_diaryDataManagerMock.Object);
 }
Example #28
0
 public async Task OnGetAsync()
 {
     DiaryNotes = await DiaryService.GetAllNotes(null, null);
 }
Example #29
0
 public DiaryController(IMapper mapper, IDiary <Diary> service)
 {
     _service = new DiaryService <DiaryData>(service, mapper);
 }
Example #30
0
 public DiaryController(DiaryService diarygService)
 {
     this._DiaryService = diarygService;
 }