/// <summary> /// Delete /// </summary> /// <param name="model">Account type model</param> /// <returns>ResponseStatusCodeHelper</returns> public ResponseStatusCodeHelper Delete(AccountTypeModel model) { try { using (var _context = new TDHEntities()) { MN_ACCOUNT_TYPE _md = _context.MN_ACCOUNT_TYPE.FirstOrDefault(m => m.id == model.ID && !m.deleted); if (_md == null) { throw new DataAccessException(FILE_NAME, "Delete", model.CreateBy); } _md.deleted = true; _md.delete_by = model.DeleteBy; _md.delete_date = DateTime.Now; _context.MN_ACCOUNT_TYPE.Attach(_md); _context.Entry(_md).State = EntityState.Modified; _context.SaveChanges(); } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "Delete", model.CreateBy, ex); } Notifier.Notification(model.CreateBy, Message.DeleteSuccess, Notifier.TYPE.Success); return(ResponseStatusCodeHelper.Success); }
public ActionResult GetAccntTypeDTable() { AccountTypeModel model = new AccountTypeModel(); List <AccntTypeList> getAccntTypeList = new List <AccntTypeList>(); var SQLQuery = "SELECT * FROM [Tbl_FMBank_AccountType]"; using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString())) { Connection.Open(); using (SqlCommand command = new SqlCommand("[dbo].[SP_Banks]", Connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery)); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { getAccntTypeList.Add(new AccntTypeList() { AccntTypeID = GlobalFunction.ReturnEmptyInt(dr[0]), AccntType = GlobalFunction.ReturnEmptyString(dr[1]) }); } } Connection.Close(); } model.getAccntTypeList = getAccntTypeList.ToList(); return(PartialView("AccountTypeTab/_TableAccountType", getAccntTypeList)); }
public ActionResult Create() { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); #endregion //Call to service AccountTypeModel model = new AccountTypeModel() { ID = Guid.NewGuid(), CreateBy = UserID, Insert = true }; // return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
/// <summary> /// Check Delete /// </summary> /// <param name="model">Account type model</param> /// <returns>ResponseStatusCodeHelper</returns> public ResponseStatusCodeHelper CheckDelete(AccountTypeModel model) { try { using (var _context = new TDHEntities()) { MN_ACCOUNT_TYPE _md = _context.MN_ACCOUNT_TYPE.FirstOrDefault(m => m.id == model.ID && !m.deleted); if (_md == null) { throw new DataAccessException(FILE_NAME, "CheckDelete", model.CreateBy); } var _account = _context.MN_ACCOUNT.FirstOrDefault(m => m.account_type_id == model.ID && !m.deleted); if (_account != null) { Notifier.Notification(model.CreateBy, Message.CheckExists, Notifier.TYPE.Warning); return(ResponseStatusCodeHelper.NG); } } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "CheckDelete", model.CreateBy, ex); } return(ResponseStatusCodeHelper.OK); }
/// <summary> /// Adds to [Account] if the types don't already exist. /// Also adds reference to account types into [User_Accounts]. (Links the account types to the user) /// </summary> /// <param name="AccountType"></param> /// <param name="UserEmail"></param> public void AddAccountType(AccountTypeModel AccountType, string UserEmail) { AddAccountTypes(new List <AccountTypeModel>() { AccountType }, UserEmail); }
public ActionResult Edit(string id) { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); // ViewBag.id = id; #endregion //Call to service AccountTypeModel model = _service.GetItemByID(new AccountTypeModel() { ID = new Guid(id), CreateBy = UserID, Insert = false }); // return(View(model)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
public JsonResult CheckDelete(AccountTypeModel model) { try { #region " [ Declaration ] " AccountTypeService _service = new AccountTypeService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; #endregion //Call to service return(this.Json(_service.CheckDelete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, UserID, ex); } }
/// <summary> /// Get item /// </summary> /// <param name="model">Account type model</param> /// <returns>MoneyAccountTypeModel</returns> public AccountTypeModel GetItemByID(AccountTypeModel model) { try { using (var _context = new TDHEntities()) { MN_ACCOUNT_TYPE _md = _context.MN_ACCOUNT_TYPE.FirstOrDefault(m => m.id == model.ID && !m.deleted); if (_md == null) { throw new DataAccessException(FILE_NAME, "GetItemByID", model.CreateBy); } return(new AccountTypeModel() { ID = _md.id, Name = _md.name, Type = _md.type, Ordering = _md.ordering, Publish = _md.publish }); } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "GetItemByID", model.CreateBy, ex); } }
public ActionResult SaveAccntType(AccountTypeModel model) { var isExist = ""; if (ModelState.IsValid) { var accntType = model.AccntTypeList.AccntType; Tbl_FMBank_AccountType checkAccntType = (from a in BOSSDB.Tbl_FMBank_AccountType where (a.AccntType == accntType) select a).FirstOrDefault(); if (model.ActionID == 1) { if (checkAccntType == null) { Tbl_FMBank_AccountType AT = new Tbl_FMBank_AccountType(); AT.AccntType = accntType; BOSSDB.Tbl_FMBank_AccountType.Add(AT); BOSSDB.SaveChanges(); isExist = "false"; } else if (checkAccntType != null) { isExist = "true"; } } else if (model.ActionID == 2) { Tbl_FMBank_AccountType AType = (from a in BOSSDB.Tbl_FMBank_AccountType where a.AccntTypeID == model.AccntTypeList.AccntTypeID select a).FirstOrDefault(); List <Tbl_FMBank_AccountType> acctypeCount = (from e in BOSSDB.Tbl_FMBank_AccountType where e.AccntType == accntType select e).ToList(); if (checkAccntType != null) { if (AType.AccntType != accntType && acctypeCount.Count >= 1) { isExist = "true"; } else { isExist = "justUpdate"; } } else if (checkAccntType == null) { isExist = "justUpdate"; } if (isExist == "justUpdate") { AType.AccntType = accntType; BOSSDB.Entry(AType); BOSSDB.SaveChanges(); } } } return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { isExist = isExist } }); }
public void Merge(AccountTypeModel source) { if (source != null) { AccountTypeId = source.AccountTypeId; AccountTypeName = source.AccountTypeName; } }
/// <summary> /// Save /// </summary> /// <param name="model">Account type model</param> /// <returns>ResponseStatusCodeHelper</returns> public ResponseStatusCodeHelper Save(AccountTypeModel model) { try { using (var _context = new TDHEntities()) { MN_ACCOUNT_TYPE _md = new MN_ACCOUNT_TYPE(); if (model.Insert) { _md.id = Guid.NewGuid(); } else { _md = _context.MN_ACCOUNT_TYPE.FirstOrDefault(m => m.id == model.ID && !m.deleted); if (_md == null) { throw new DataAccessException(FILE_NAME, "Save", model.CreateBy); } } _md.name = model.Name; _md.type = model.Type; _md.ordering = model.Ordering; _md.publish = model.Publish; if (model.Insert) { _md.create_by = model.CreateBy; _md.create_date = DateTime.Now; _context.MN_ACCOUNT_TYPE.Add(_md); _context.Entry(_md).State = EntityState.Added; } else { _md.update_by = model.UpdateBy; _md.update_date = DateTime.Now; _context.MN_ACCOUNT_TYPE.Attach(_md); _context.Entry(_md).State = EntityState.Modified; } _context.SaveChanges(); } } catch (DataAccessException fieldEx) { throw fieldEx; } catch (Exception ex) { throw new ServiceException(FILE_NAME, "Save", model.CreateBy, ex); } if (model.Insert) { Notifier.Notification(model.CreateBy, Message.InsertSuccess, Notifier.TYPE.Success); } else { Notifier.Notification(model.CreateBy, Message.UpdateSuccess, Notifier.TYPE.Success); } return(ResponseStatusCodeHelper.Success); }
public AccountType AccountTypeModelToAccountType(AccountTypeModel AccountTypeModel) { var AccountType = new AccountType(); AccountType.AccountName = AccountTypeModel.AccountName; AccountType.InterestRate = AccountTypeModel.InterestRate; return(AccountType); }
public AccountTypeModel AccountTypeToAccountTypeModel(AccountType AccountType) { IApplicationLogic applicationLogic = new ApplicationLogic(_session); var AccountTypeModel = new AccountTypeModel(); AccountTypeModel.AccountName = AccountType.AccountName; AccountTypeModel.InterestRate = AccountType.InterestRate; return(AccountTypeModel); }
public AccountTypeModel CreateViewModel(AccountType model) { AccountTypeModel viewModel = null; if (model != null) { viewModel = new AccountTypeModel(); CommonMethods.CopyObjectProperties(model, viewModel); } return(viewModel); }
public ActionResult GetAccntTypeForm(int ActionID, int PrimaryID) { AccountTypeModel model = new AccountTypeModel(); if (ActionID == 2) { var bank = (from a in BOSSDB.Tbl_FMBank_AccountType where a.AccntTypeID == PrimaryID select a).FirstOrDefault(); model.AccntTypeList.AccntType = bank.AccntType; model.AccntTypeList.AccntTypeID = bank.AccntTypeID; } model.ActionID = ActionID; return(PartialView("AccountTypeTab/_AccountTypeForm", model)); }
public ActionResult Create() { // Null handling if (Session["loggedInState"] == null) { return(Redirect("/403.html")); } else { AccountTypeModel typeModel = new AccountTypeModel(); List <Account_Type> acounttypeList = typeModel.ListAccounts(); return(View(acounttypeList)); } }
/// <summary> /// Returns a list of AccountTypes for a given user /// </summary> /// <param name="UID"></param> /// <returns></returns> public List <AccountTypeModel> GetAccountTypesByUID(string UID) { List <AccountTypeModel> AccountTypes = new List <AccountTypeModel>(); try { SqlDataProvider db = new SqlDataProvider(); string query = "SELECT ID, Type FROM [dbo].[User_Accounts] UA left join [dbo].[Account] A on UA.Account_ID = A.ID Where UA.UID = '" + UID + "';"; using (SqlConnection connection = (SqlConnection)db.GetConnection()) { connection.Open(); SqlCommand command = db.CreateCommand(query, connection); SqlDataReader reader = db.ExecuteReader(command); while (reader.Read()) { AccountTypeModel AccountType = new AccountTypeModel() { ID = Utilities.ParseInt(reader["ID"].ToString()), AccountType = reader["Type"].ToString() }; AccountTypes.Add(AccountType); } reader.Close(); } } catch (Exception ex) { throw ex; } return(AccountTypes); }
/// <summary> /// Gets record from [Account] where the Account Type ID matches. /// (Gets from [Account] and not [User_Accounts] which relates [Account] to [ASP_NET_User]) /// </summary> /// <param name="ID"></param> /// <returns></returns> public AccountTypeModel GetAccountTypeByID(long ID) { AccountTypeModel accountType = new AccountTypeModel(); try { SqlDataProvider db = new SqlDataProvider(); string query = "SELECT * FROM [dbo].[Account] a WHERE a.ID = " + ID + ";"; using (SqlConnection connection = (SqlConnection)db.GetConnection()) { connection.Open(); SqlCommand command = db.CreateCommand(query, connection); SqlDataReader reader = db.ExecuteReader(command); while (reader.Read()) { accountType = new AccountTypeModel() { ID = Utilities.ParseInt(reader["ID"].ToString()), AccountType = reader["AccountType"].ToString() }; } reader.Close(); } } catch (Exception ex) { throw ex; } return(accountType); }
public List <AccountTypeModel> GetServicesAndLabor() { var accountTypes = AccountTypeRepository.GetAccountTypes().OrderBy(o => o.Description); List <AccountTypeModel> tree = new List <AccountTypeModel>(); foreach (var accountType in accountTypes) { AccountTypeModel anode = new AccountTypeModel(); anode.Id = accountType.Id; anode.Description = accountType.Description; anode.TaxRate = (decimal)accountType.TaxRate; foreach (var service in accountType.ServiceTypeList.OrderBy(o => o.ServiceType.Description)) { AccountTypeServiceModel snode = new AccountTypeServiceModel(); snode.Parent = anode; snode.Id = service.Id; snode.ServiceTypeId = service.ServiceType.Id; snode.ServiceTypeDescription = service.ServiceType.Description; anode.Services.Add(snode); foreach (var labor in service.LaborTypeList.OrderBy(o => o.LaborType.Description)) { AccountTypeLaborModel lnode = new AccountTypeLaborModel(); lnode.Parent = snode; lnode.Id = labor.Id; lnode.LaborTypeId = labor.LaborType.Id; lnode.LaborTypeDescription = labor.LaborType.Description; snode.Labor.Add(lnode); } } tree.Add(anode); } return(tree); }
public void Update(AccountTypeModel model) { _queueProducer.Send(model); }
private static void UpdateDatabase(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope()) using (var context = serviceScope.ServiceProvider.GetRequiredService<Lab6DbContext>()) { context.Database.Migrate(); context.Database.EnsureCreated(); if (!context.Set<UserModel>().Any()) { var user = new UserModel { Name = "Stalin" }; context.Add(user); var baseAccountType = new AccountTypeModel { Name = "Base", BonusPercent = 3 }; var goldAccountType = new AccountTypeModel { Name = "Gold", BonusPercent = 23 }; var platinumAccountType = new AccountTypeModel { Name = "Platinum ", BonusPercent = 43 }; context.AddRange(baseAccountType, goldAccountType, platinumAccountType); context.Add(new AccountModel { OwnerUser = user, AccountType = baseAccountType, Balance = 444, Bonus = 23, Number = "DX234(base)" }); context.Add(new AccountModel { OwnerUser = user, AccountType = goldAccountType, Balance = 64, Bonus = 22, Number = "DX235(gold)" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX236(plat)" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2362" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2364" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2365" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2366" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2367" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2369" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2376" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2356" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2336" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2316" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2326" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2364" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2365" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2366" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2367" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2369" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2376" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2356" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2336" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2316" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2326" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2364" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2365" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2366" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2367" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2368" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2369" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2376" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2356" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2336" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2316" }); context.Add(new AccountModel { OwnerUser = user, AccountType = platinumAccountType, Balance = 42, Bonus = 266, Number = "DX2326" }); context.SaveChanges(); } } }
public IActionResult Put(string uid, [FromBody] AccountTypeModel model) { model.Uid = uid; _useCase.Update(model); return(Ok(model)); }