Пример #1
0
        public async Task<bool> CreateAssignment(Assignment assignment)
        {
            assignment.CreateDate = DateTime.UtcNow;
            assignment.UpdateDate = DateTime.UtcNow;
            db.Entry(assignment).State = EntityState.Added;
            assignment.Key = assignment.Key != null ? assignment.Key.Trim() : null;

            db.Assignments.Add(assignment);
            try
            {
                await db.SaveChangesAsync();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Пример #2
0
        public async Task<bool> EditAssignment(Assignment assignment)
        {

            db.Entry(assignment).State = EntityState.Modified;
            db.Entry(assignment).Property(prop => prop.UpdateDate).IsModified = false;
            db.Entry(assignment).Property(prop => prop.CreateDate).IsModified = false;
            assignment.Key = assignment.Key != null ? assignment.Key.Trim() : null;
            
            try
            {
                await db.SaveChangesAsync();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }