public PenaltyLogDTO Insert(PenaltyLogDTO penaltylog) { try { using (var context = DataAccessHelper.CreateContext()) { PenaltyLog entity = _mapper.Map <PenaltyLog>(penaltylog); context.PenaltyLog.Add(entity); context.SaveChanges(); return(_mapper.Map <PenaltyLogDTO>(penaltylog)); } } catch (Exception e) { Logger.Error(e); return(null); } }
public void Update(PenaltyLogDTO penaltylog) { try { using (var context = DataAccessHelper.CreateContext()) { PenaltyLog result = context.PenaltyLog.FirstOrDefault(c => c.AccountId == penaltylog.AccountId && c.PenaltyLogId == penaltylog.PenaltyLogId); if (result != null) { penaltylog.PenaltyLogId = result.PenaltyLogId; _mapper.Map(penaltylog, result); context.SaveChanges(); } } } catch (Exception e) { Logger.Error(e); } }
public DeleteResult Delete(int penaltylogid) { try { using (var context = DataAccessHelper.CreateContext()) { PenaltyLog PenaltyLog = context.PenaltyLog.FirstOrDefault(c => c.PenaltyLogId.Equals(penaltylogid)); if (PenaltyLog != null) { context.PenaltyLog.Remove(PenaltyLog); context.SaveChanges(); } return(DeleteResult.Deleted); } } catch (Exception e) { Logger.Log.Error(String.Format(Language.Instance.GetMessageFromKey("DELETE_PENALTYLOG_ERROR"), penaltylogid, e.Message), e); return(DeleteResult.Error); } }