Esempio n. 1
0
        public int CreateCenter(Centers center)
        {
            var output = 0;

            Utilities.Try(() =>
            {
                Guard.NotNullOrEmpty(center.Name, "Name of Center is required.,");
                Guard.NotNullOrEmpty(center.LocationAddress, "Address of Centers is required.,");
                using (var transaction = new TransactionScope())
                {
                    var cent = _centerRepo.GetCenterByName(center.Name, center.EmiratesId);
                    if (cent == null)
                    {
                        var centOut = _centerRepo.CreateCenter(center);
                        if (centOut == 0)
                        {
                            throw new Exception("Unable to Add Centers");
                        }
                        output = centOut;
                    }
                    else
                    {
                        throw new Exception("Unable to add centers with the same emirates.,");
                    }
                    transaction.Complete();
                    transaction.Dispose();
                }
            }, "CreateCenter(Centers center)", log);

            return(output);
        }