Exemplo n.º 1
0
        public ConsumerEmployee GetModel()
        {
            ConsumerEmployee model = new ConsumerEmployee();

            CustomMapper.MapEntity(this, model);

            if (this.ConsumerEmployeeId.HasValue)
            {
                model.ConsumerEmployeeId = this.ConsumerEmployeeId.Value;
            }
            else
            {
                model.ConsumerEmployeeId = 0;
            }

            return(model);
        }
Exemplo n.º 2
0
        public async Task <Int32> Save(ConsumerEmployee dbModel)
        {
            if (dbModel.ConsumerEmployeeId == 0)
            {
                _context.ConsumerEmployees.Add(dbModel);
            }
            else
            {
                var model = await _context.ConsumerEmployees.SingleOrDefaultAsync(x => x.ConsumerEmployeeId == dbModel.ConsumerEmployeeId);

                if (model != null)
                {
                    ITCraftFrame.CustomMapper.MapEntity(dbModel, model);
                }
            }
            await _context.SaveChangesAsync();

            return(dbModel.ConsumerEmployeeId);
        }
Exemplo n.º 3
0
        public ConsumerEmployeeViewModel(ConsumerEmployee model)
        {
            CustomMapper.MapEntity(model, this);
            var employeeFiles = ConsumerEmployeeManagement.GetFilesByConsumerEmployeeId(model.ConsumerEmployeeId).FirstOrDefault();

            FileId   = employeeFiles?.Id;
            FileName = employeeFiles?.FileDisplayName;

            this.ContactName = model.Contact.FirstName + " " + model.Contact.LastName;
            if (this.ServiceId.HasValue)
            {
                this.ServiceName = model.ServicesList.ServiceDescription;
            }

            if (model.Contact.AgencyNameId.HasValue)
            {
                this.CompanyName = model.Contact.Agency.NameCompany;
            }
        }