public static List <LimitationEmailViewModel> ConvertToLimitationEmailViewModelList(this IEnumerable <LimitationEmail> LimitationEmails)
        {
            List <LimitationEmailViewModel> viewModels = new List <LimitationEmailViewModel>();

            foreach (LimitationEmail LimitationEmail in LimitationEmails)
            {
                viewModels.Add(LimitationEmail.ConvertToLimitationEmailViewModel());
            }
            return(viewModels);
        }
        public LimitationEmail Delete(Guid identifier)
        {
            // Load LimitationEmail that will be deleted
            LimitationEmail dbEntry = context.LimitationEmails
                                      .FirstOrDefault(x => x.Identifier == identifier);

            if (dbEntry != null)
            {
                // Set activity
                dbEntry.Active = false;
                // Set timestamp
                dbEntry.UpdatedAt = DateTime.Now;
            }

            return(dbEntry);
        }
        public static LimitationEmailViewModel ConvertToLimitationEmailViewModelLite(this LimitationEmail LimitationEmail)
        {
            LimitationEmailViewModel LimitationEmailViewModel = new LimitationEmailViewModel()
            {
                Id         = LimitationEmail.Id,
                Identifier = LimitationEmail.Identifier,

                Name     = LimitationEmail.Name,
                LastName = LimitationEmail.LastName,
                Email    = LimitationEmail.Email,

                IsActive = LimitationEmail.Active,

                UpdatedAt = LimitationEmail.UpdatedAt,
                CreatedAt = LimitationEmail.CreatedAt
            };

            return(LimitationEmailViewModel);
        }
예제 #4
0
        public LimitationEmailResponse Create(LimitationEmailViewModel re)
        {
            LimitationEmailResponse response = new LimitationEmailResponse();

            try
            {
                LimitationEmail addedLimitationEmail = unitOfWork.GetLimitationEmailRepository().Create(re.ConvertToLimitationEmail());
                unitOfWork.Save();
                response.LimitationEmail = addedLimitationEmail.ConvertToLimitationEmailViewModel();
                response.Success         = true;
            }
            catch (Exception ex)
            {
                response.LimitationEmail = new LimitationEmailViewModel();
                response.Success         = false;
                response.Message         = ex.Message;
            }

            return(response);
        }
예제 #5
0
        public LimitationEmailResponse Delete(Guid identifier)
        {
            LimitationEmailResponse response = new LimitationEmailResponse();

            try
            {
                LimitationEmail deletedLimitationEmail = unitOfWork.GetLimitationEmailRepository().Delete(identifier);

                unitOfWork.Save();

                response.LimitationEmail = deletedLimitationEmail?.ConvertToLimitationEmailViewModel();
                response.Success         = true;
            }
            catch (Exception ex)
            {
                response.LimitationEmail = new LimitationEmailViewModel();
                response.Success         = false;
                response.Message         = ex.Message;
            }

            return(response);
        }
        public static LimitationEmail ConvertToLimitationEmail(this LimitationEmailViewModel LimitationEmailViewModel)
        {
            LimitationEmail LimitationEmail = new LimitationEmail()
            {
                Id         = LimitationEmailViewModel.Id,
                Identifier = LimitationEmailViewModel.Identifier,

                Name     = LimitationEmailViewModel.Name,
                LastName = LimitationEmailViewModel.LastName,
                Email    = LimitationEmailViewModel.Email,

                Active = LimitationEmailViewModel.IsActive,

                CreatedById = LimitationEmailViewModel.CreatedBy?.Id ?? null,
                CompanyId   = LimitationEmailViewModel.Company?.Id ?? null,

                CreatedAt = LimitationEmailViewModel.CreatedAt,
                UpdatedAt = LimitationEmailViewModel.UpdatedAt
            };

            return(LimitationEmail);
        }
        public LimitationEmail Create(LimitationEmail LimitationEmail)
        {
            if (context.LimitationEmails.Where(x => x.Identifier != null && x.Identifier == LimitationEmail.Identifier).Count() == 0)
            {
                LimitationEmail.Id = 0;

                LimitationEmail.Active = true;

                LimitationEmail.UpdatedAt = DateTime.Now;
                LimitationEmail.CreatedAt = DateTime.Now;

                context.LimitationEmails.Add(LimitationEmail);
                return(LimitationEmail);
            }
            else
            {
                // Load LimitationEmail that will be updated
                LimitationEmail dbEntry = context.LimitationEmails
                                          .FirstOrDefault(x => x.Identifier == LimitationEmail.Identifier && x.Active == true);

                if (dbEntry != null)
                {
                    dbEntry.CompanyId   = LimitationEmail.CompanyId ?? null;
                    dbEntry.CreatedById = LimitationEmail.CreatedById ?? null;

                    // Set properties
                    dbEntry.Name     = LimitationEmail.Name;
                    dbEntry.LastName = LimitationEmail.LastName;
                    dbEntry.Email    = LimitationEmail.Email;

                    // Set timestamp
                    dbEntry.UpdatedAt = DateTime.Now;
                }

                return(dbEntry);
            }
        }