public GiftTypeViewModel AddGiftType(GiftTypeViewModel model)
        {
            try
            {
                model.IsValid = model.Validate();
                if (model.IsValid)
                {
                    //if (_bdmSvc.CityCodeExists(AppConstants.SITE_CODE, model.City.CityCode))
                    //{
                    //    model.FieldId = "cityCode";
                    //    model.Message = string.Format(AppConstants.VALIDATION_ALREADY_EXISTS, "City Code");
                    //    model.IsValid = false;
                    //}

                    //if (model.IsValid)
                    //{
                        model.GiftType.SiteCode = AppConstants.SITE_CODE;
                        model.GiftType.EntityTypeCode = EntityTypeCodes.GFT.ToString();
                        _alKhairSvc.AddGiftType(model.GiftType);

                        model.FieldId = "code";
                        model.GiftType = new GiftTypeBE();
                        model.GiftTypes = _alKhairSvc.GetViewOfAllGiftTypes(AppConstants.SITE_CODE, EntityTypeCodes.GFT.ToString());
                        model.Message = string.Format(AppConstants.CRUD_CREATE, "Gift Type");
                    //}
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
            }

            return model;
        }
        public GiftTypeViewModel ModifyGiftType(GiftTypeBE mod)
        {
            GiftTypeViewModel model = new GiftTypeViewModel();

            try
            {
                DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete;
                mod.SiteCode = AppConstants.SITE_CODE;
                model.GiftType = mod;
                model.IsValid = model.Validate();
                if (model.IsValid)
                {
                    //_bdmSvc.ModifyEntity(mod);
                    _alKhairSvc.ModifyGiftType(mod);

                    model.FieldId = "code";
                    model.GiftType = new GiftTypeBE();
                    model.GiftTypes = _alKhairSvc.GetViewOfAllGiftTypes(AppConstants.SITE_CODE, EntityTypeCodes.GFT.ToString());
                    model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Gift Type") : string.Format(AppConstants.CRUD_DELETE, "Gift Type");
                }
            }
            catch (Exception ex)
            {
                model.IsValid = false;
                model.Message = ex.Message;
                if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."))
                    model.Message = "Unable to modify Region Code";
            }
            return model;
        }
 public GiftTypeViewModel GetAllGiftTypes()
 {
     var mod = new GiftTypeViewModel();
     mod.IsValid = true;
     try
     {
         mod.GiftTypes = _alKhairSvc.GetViewOfAllGiftTypes(AppConstants.SITE_CODE, EntityTypeCodes.GFT.ToString());
     }
     catch (Exception ex)
     {
         mod.IsValid = false;
         mod.Message = ex.Message;
     }
     return mod;
 }