public ExecuteResult Execute([FromBody] CountryVM model) { try { using (CountryOperation operation = new CountryOperation()) { switch (model.OperationType) { case OperationType.Save: string flagName = model.Country.Code + "-{0}.png"; model.Country.Flag = flagName; operation.Save(model.Country); File.WriteAllBytes(AppConfig.FlagPath + string.Format(flagName, AppConfig.FlagResolution), model.Flag); break; case OperationType.Update: model.Country.Flag = operation.GetFlagName(model.Country.Id); operation.Update(model.Country); File.WriteAllBytes(AppConfig.FlagPath + string.Format(model.Country.Code + "-{0}.png", AppConfig.FlagResolution), model.Flag); break; case OperationType.Delete: operation.Delete(model.Country); break; } return(new ExecuteResult { Succeeded = true, ResultMessage = "İşleminiz gerçekleştirilmiştir." }); } } catch (System.Exception ex) { Log4NetManager.Error("İşlem sırasında hata alındı.", ex); return(new ExecuteResult { Succeeded = false, ResultMessage = "Beklenmedik bir hata oluştu." }); } }
public ExecuteResult Execute(UIModel model) { CountryOperation operation = CountryOperation.Instance; CountryVM vm = model as CountryVM; switch (model.OperationType) { case OperationType.Save: return(operation.Save <Country>(vm.Country)); case OperationType.Update: return(operation.Update <Country>(vm.Country)); case OperationType.Delete: return(operation.Delete <Country>(vm.Country)); default: return(new ExecuteResult { Succeeded = false, ResultMessage = "İşlem tipi hatalı" }); } }