Beispiel #1
0
        public static EventMD Translate(this EventDE from)
        {
            var to = new EventMD();

            to.Id          = from.Id;
            to.Description = from.Description;
            to.CustomerId  = from.CustomerId.Value;
            to.CompanyId   = from.CompanyId;
            to.CreatedDate = from.CreatedDate;
            to.CreatedById = from.CreatedById;
            to.EventStatus = from.EventStatus;
            to.IsValid     = from.IsValid;

            return(to);
        }
Beispiel #2
0
        public EventMD ModifyEvent(EventMD mod)
        {
            var entity = mod.Translate();

            try
            {
                _EventRepo.Update(entity);
                _EventRepo.CommitAllChanges();
                mod.AddSuccessMessage(string.Format(AppConstants.CRUD_UPDATE, "Event"));
            }
            catch (Exception)
            {
                mod.AddSuccessMessage(string.Format(AppConstants.CRUD_UPDATE_ERROR, "Event"));
            }

            return(mod);
        }
Beispiel #3
0
        public EventMD AddEvent(EventMD mod)
        {
            try
            {
                var entity = mod.Translate();
                _EventRepo.Insert(entity);
                _EventRepo.CommitAllChanges();
                mod.AddSuccessMessage(string.Format(AppConstants.CRUD_ADD, "Event"));
                mod.Id = entity.Id;
            }
            catch (Exception ex)
            {
                mod.HasErrors = true;
                mod.AddErrorMessage(string.Format(AppConstants.CRUD_ADD_ERROR, "Event"));
            }

            return(mod);
        }
Beispiel #4
0
        public EventMD DeleteEvent(long id)
        {
            var mod = new EventMD();

            try
            {
                var Event = _EventRepo.Fetch(x => x.IsActive);
                Event.IsActive = false;
                _EventRepo.Update(Event);
                _EventRepo.CommitAllChanges();

                mod.AddSuccessMessage(string.Format(AppConstants.CRUD_DELETE, "Event"));
            }
            catch (Exception ex)
            {
                mod.AddErrorMessage(string.Format(AppConstants.CRUD_DELETE_ERROR, "Event"));
            }
            return(mod);
        }
Beispiel #5
0
        public static List <EventMD> Translate(this List <EventDE> list)
        {
            var events = new List <EventMD>();

            foreach (var from in list)
            {
                var to = new EventMD();

                to.Id          = from.Id;
                to.Description = from.Description;
                to.CustomerId  = from.CustomerId.Value;
                to.CompanyId   = from.CompanyId;
                to.CreatedDate = from.CreatedDate;
                to.CreatedById = from.CreatedById;
                to.EventStatus = from.EventStatus;
                to.IsValid     = from.IsValid;
                events.Add(to);
            }
            return(events);
        }
Beispiel #6
0
        public async Task <ActionResult> AddSchedule(ScheduleViewModel model)
        {
            //if (model.Gender != Gender.Male || model.Gender != Gender.Female) model.Gender
            if (ModelState.IsValid)
            {
                var eventmd = new EventMD();
                eventmd.Description = model.EventDescription;
                eventmd.EventStatus = EventStatus.Pending;
                var result = _eventService.AddEvent(eventmd);

                if (!result.HasErrors)
                {
                    ScheduleMD schedule = new ScheduleMD();
                    schedule.Date        = model.Date;
                    schedule.StartTime   = model.StartTime;
                    schedule.EndTime     = model.EndTime;
                    schedule.AddressLine = model.AddressLine;
                    schedule.City        = model.City;
                    schedule.Province    = model.Province;
                    schedule.Country     = model.Country;

                    schedule.CreatedDate = DateTime.Now;
                    schedule.CreatedById = Convert.ToInt64(User.Identity.GetUserId());
                    schedule.IsValid     = true;

                    var res = _scheduleService.AddSchedule(schedule);
                    if (res.HasErrors)
                    {
                        model.HasError = true;
                        //model.ErrorMessage.Message = res.ResultMessages.FirstOrDefault().Message;
                        //model.ErrorMessage.MessageType =  "Try again! " + res.ResultMessages.FirstOrDefault().MessageType;
                        //await UserManager.DeleteAsync(user);
                    }

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(model));
        }
Beispiel #7
0
        public static EventDE Translate(this EventMD from, EventDE dest = null)
        {
            var to = dest ?? new EventDE();

            if (to.Id <= 0)
            {
                to.Id       = from.Id;
                to.IsActive = true;
            }
            else
            {
                to.IsActive = from.IsActive;
            }
            to.Description = from.Description;
            to.CustomerId  = from.CustomerId;
            to.CompanyId   = from.CompanyId;
            to.CreatedDate = from.CreatedDate;
            to.CreatedById = from.CreatedById;
            to.EventStatus = from.EventStatus;
            to.IsValid     = from.IsValid;


            return(to);
        }