Esempio n. 1
0
        public int AddEditActivity(AngularActivity selectedActivity)
        {
            int newId = 0;
            string success = "ono";
            try
            {
                using (var db = new curtisGodaddyEntities())
                {
                    JobSearchActivity dbJobSearchActivity = null;
                    if (selectedActivity.ActivityId == 0)
                    {
                        dbJobSearchActivity = new JobSearchActivity { };
                        dbJobSearchActivity.JobListingId = selectedActivity.JobListingId;
                        db.JobSearchActivities.Add(dbJobSearchActivity);
                    }
                    else
                    {
                        dbJobSearchActivity = db.JobSearchActivities.Where(j => j.JobSearchActivityId == selectedActivity.ActivityId).First();
                    }
                    dbJobSearchActivity.Comments = selectedActivity.Comments;
                    dbJobSearchActivity.ActivityDate = DateTime.Parse(selectedActivity.ActivityDate);
                    dbJobSearchActivity.ActivityStatus = selectedActivity.ActivityStatus;

                    db.SaveChanges();
                    newId = dbJobSearchActivity.JobSearchActivityId;
                    success = "ok";
                }
            }
            catch (DbEntityValidationException ex)
            {
                success = "ValidationExceptions: ";
                foreach (var eve in ex.EntityValidationErrors)
                {
                    success += eve.Entry.Entity.GetType().Name + ": " + eve.Entry.State;
                    foreach (var ve in eve.ValidationErrors)
                    {
                        success += " Property: " + ve.PropertyName + " Error: " + ve.ErrorMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                success = ex.Message;
                if (ex.InnerException != null)
                    success += " inner: " + ex.InnerException.Message;
            }
            return newId;
        }
Esempio n. 2
0
        public JobActivityModel GetJobSearchActivities(int selectedJobListingId)
        {
            JobActivityModel jobActivityModel = new JobActivityModel();
            using (var db = new curtisGodaddyEntities())
            {
                var activitites = db.JobSearchActivities.Where(jl => jl.JobListingId == selectedJobListingId).ToList();
                foreach (JobSearchActivity ja in activitites)
                {
                    var item = new AngularActivity()
                    {
                        JobListingId = selectedJobListingId,
                        ActivityId = ja.JobSearchActivityId,
                        ActivityDate = ja.ActivityDate.ToShortDateString(),
                        ActivityStatus = ja.ActivityStatus.Value,
                        Comments = ja.Comments
                    };
                    jobActivityModel.Activitites.Add(item);
                }
                jobActivityModel.ActivityTypes = GetRefs(1);

                return jobActivityModel;
            }
        }