Exemple #1
0
        public ProjectFeedModel(ProjectFeed projectFeed)
        {
            Type        = projectFeed.Type;
            Title       = projectFeed.Title;
            SkillLevel  = projectFeed.SkillLevel;
            Budget      = projectFeed.Budget;
            Name        = projectFeed.Name;
            Address     = projectFeed.Address;
            Details     = projectFeed.Details;
            Type        = projectFeed.Type;
            Id          = projectFeed.Id.ToString();
            CreatedById = projectFeed.CreatedById;
            AssignTo    = Convert.ToString(projectFeed.AssignedTo);

            CreatedDate = projectFeed.CreatedDate;
            DueDate     = DueDate;



            Account = new AccountModel()
            {
                Rating            = 3.5,
                IsVerified        = true,
                IsPaymentVerified = true
            };
            Bids = new List <BidViewModel>();
            if (projectFeed.Bids != null)
            {
                foreach (var bid in projectFeed.Bids)
                {
                    Bids.Add(new BidViewModel(bid));
                }
            }
        }
Exemple #2
0
        private async Task <ProjectFeed> GetOrCreateProjectFeedCacheAsync()
        {
            ProjectFeed result = null;

            if (!_cache.TryGetValue <ProjectFeed>(_config.ProjectFeedCacheKey, out result))
            {
                result = await _feedService.GetProjectFeed();

                if (result != null)
                {
                    _cache.Set(
                        _config.ProjectFeedCacheKey,
                        result,
                        new MemoryCacheEntryOptions()
                        .SetSlidingExpiration(TimeSpan.FromSeconds(_config.CacheDurationInSeconds))
                        );
                }
            }

            if (result == null)
            {
                throw new InvalidOperationException("failed to retrieve project feed");
            }

            return(result);
        }
Exemple #3
0
 private async Task EnsureProjectFeed()
 {
     if (_projectFeed == null)
     {
         _projectFeed = await GetOrCreateProjectFeedCacheAsync();
     }
 }
 public bool AddProject(ProjectFeed param)
 {
     try
     {
         _collection.InsertOne(param);
         return(true);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message);
     }
     return(false);
 }
Exemple #5
0
        public IActionResult CreateProjectFeed(CreateProjectFeedModel model)
        {
            ViewData["Message"] = "Create Feed page.";

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var accountId    = HttpContext.Session.GetString("accountId");
            var accountEmail = HttpContext.Session.GetString("accountEmail");

            if (accountId == null)
            {
                return(RedirectToAction("/Account/SignIn"));
            }

            var projectDto = new ProjectFeed()
            {
                Type       = model.Type,
                Title      = model.Title,
                SkillLevel = model.SkillLevel,
                Budget     = model.Budget,
                Name       = model.Name,
                Address    = model.Address,
                Details    = model.Details,

                CreatedById    = accountId,
                CreatedByEmail = accountEmail
            };

            var result = _repo.AddProject(projectDto);

            if (result)
            {
                return(RedirectToAction("GetProjectFeeds"));
            }
            return(View(@"/Views/Home/CreateProjectFeed.cshtml", model));
        }