Пример #1
0
        public IHttpActionResult Create([FromBody] Entities.Table.Sucursal entity)
        {
            try
            {
                if (entity != null)
                {
                    using (var scope = new TransactionScope())
                    {
                        var save = new Business.Table.Sucursal(entity).Save();
                        if (save.result.Success)
                        {
                            scope.Complete();

                            return(Created <Entities.Table.Sucursal>($"{Request.RequestUri}/{save.domain?.Id?.ToString()}", save.domain?.Data?.Entity));
                        }

                        return(InternalServerError());
                    }
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #2
0
        public IHttpActionResult Update(int id, [FromBody] Entities.Table.Sucursal entity)
        {
            try
            {
                if (entity != null)
                {
                    var load = new Business.Table.Sucursal()
                    {
                        Id = id
                    }.Load();
                    if (load.result.Success)
                    {
                        if (load.domain != null)
                        {
                            load.domain.Entity = entity;

                            using (var scope = new TransactionScope())
                            {
                                var save = load.domain.Save();
                                if (save.result.Success)
                                {
                                    scope.Complete();

                                    return(Ok(save.domain?.Data?.Entity));
                                }

                                return(InternalServerError());
                            }
                        }

                        return(NotFound());
                    }

                    return(InternalServerError());
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #3
0
 public Data(Entities.Table.Sucursal Sucursal)
 {
     Entity = Sucursal;
 }
Пример #4
0
 public Sucursal(Entities.Table.Sucursal entity)
     : this(entity, "test.connectionstring.name")
 {
 }