Esempio n. 1
0
        public static ARC CreateARC(ARC arc)
        {
            using (LinqToSqlDataContext db = new LinqToSqlDataContext())
            {
                if (string.IsNullOrEmpty(arc.UNiqueCode))
                {
                    ISingleResult <SP_GenerateAccountUniqueCodeResult> result = db.SP_GenerateAccountUniqueCode(arc.CompanyName, arc.ArcTypeId.HasValue ? arc.ArcTypeId : 1, arc.CreatedBy);
                    if (result == null)
                    {
                        throw new Exception("Unable to Generate a Unique Code using the SP: SP_GenerateAccountUniqueCode");
                    }
                    else
                    {
                        arc.UNiqueCode = result.FirstOrDefault().Column1.Value.ToString();
                    }
                }
                db.ARCs.InsertOnSubmit(arc);
                db.SubmitChanges();
            }

            return(arc); //returns the same object with ARCId filled in
        }