public Int32 insertTaxType(Models.MstTaxType taxType) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstTaxType newTaxType = new Data.MstTaxType(); newTaxType.TaxType = taxType.TaxType; newTaxType.TaxRate = taxType.TaxRate; newTaxType.IsInclusive = taxType.IsInclusive; newTaxType.AccountId = taxType.AccountId; newTaxType.IsLocked = taxType.IsLocked; newTaxType.CreatedById = userId; newTaxType.CreatedDateTime = DateTime.Now; newTaxType.UpdatedById = userId; newTaxType.UpdatedDateTime = DateTime.Now; db.MstTaxTypes.InsertOnSubmit(newTaxType); db.SubmitChanges(); return(newTaxType.Id); } catch { return(0); } }
public HttpResponseMessage AddTaxType(Entities.MstTaxType objTaxType) { try { var currentUser = from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d; if (currentUser.Any()) { var currentUserId = currentUser.FirstOrDefault().Id; var userForms = from d in db.MstUserForms where d.UserId == currentUserId && d.SysForm.FormName.Equals("SystemTables") select d; if (userForms.Any()) { if (userForms.FirstOrDefault().CanAdd) { var accounts = from d in db.MstAccounts.OrderBy(d => d.Account) where d.IsLocked == true select d; if (accounts.Any()) { Data.MstTaxType newTaxType = new Data.MstTaxType { TaxType = objTaxType.TaxType, TaxRate = objTaxType.TaxRate, IsInclusive = objTaxType.IsInclusive, AccountId = objTaxType.AccountId, IsLocked = true, CreatedById = currentUserId, CreatedDateTime = DateTime.Now, UpdatedById = currentUserId, UpdatedDateTime = DateTime.Now }; db.MstTaxTypes.InsertOnSubmit(newTaxType); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK, newTaxType.Id)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "No account found. Please setup at least one account for tax types.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no rights to add tax type.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no access for this system table page.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Theres no current user logged in.")); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's went wrong from the server.")); } }
public Int32 insertTaxType(Models.MstTaxType taxType) { try { var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault(); Data.MstTaxType newTaxType = new Data.MstTaxType(); newTaxType.TaxType = taxType.TaxType; newTaxType.TaxRate = taxType.TaxRate; newTaxType.IsInclusive = taxType.IsInclusive; newTaxType.AccountId = taxType.AccountId; newTaxType.IsLocked = taxType.IsLocked; newTaxType.CreatedById = userId; newTaxType.CreatedDateTime = DateTime.Now; newTaxType.UpdatedById = userId; newTaxType.UpdatedDateTime = DateTime.Now; db.MstTaxTypes.InsertOnSubmit(newTaxType); db.SubmitChanges(); return newTaxType.Id; } catch { return 0; } }