/// <summary> /// Delete an entity. /// </summary> /// <param name="model"></param> public void Delete(ClosedMonthViewModel model) { var entity = model.ToEntity(); this._ClosedMonthsRepository.Delete(entity); #region Commit Changes this._unitOfWork.Commit(); #endregion }
/// <summary> /// Add an entity. /// </summary> /// <param name="model"></param> /// <returns></returns> public ClosedMonthViewModel Add(ClosedMonthViewModel model) { //model.To = model.To.SetTimeToMax(); //this.ThrowExceptionIfExist(model); this.ValidateFromAndTo(model); var entity = model.ToEntity(); entity.Month = (byte)model.From.Value.Month; entity = this._ClosedMonthsRepository.Add(entity); var entityAr = new ClosedMonth { Id = entity.Id, Name = model.NameAr, Description = model.DescriptionAr, Language = Language.Arabic }; entity.ChildTranslatedClosedMonths.Add(entityAr); this._ClosedMonthsRepository.Add(entityAr); var entityEn = new ClosedMonth { Id = entity.Id, Name = model.NameEn, Description = model.DescriptionEn, Language = Language.English }; entity.ChildTranslatedClosedMonths.Add(entityEn); this._ClosedMonthsRepository.Add(entityEn); #region Commit Changes this._unitOfWork.Commit(); #endregion model = entity.ToModel(); return(model); }